回到顶部

阅读目录

Centos7 使用 Supervisor 守护进程 Celery

Supervisor 官网

Supervisor 安装

Supervisor 守护进程

supervisor.conf 配置

supervisor.conf 文件路径:/etc/supervisord.d

主要配置包含子文件的配置,同级 conf.d 目录,以 .ini 结尾的配置文件

[include]
files = ./conf.d/*.ini

新建 supervisor ini 文件

在 /etc/supervisord.d/conf.d 目录,新建 .ini 文件,如下

Supervisor 守护 DJCelery 配置文件

  1.  python manage.py celery -A HttpRunnerManager worker --loglevel=info # 启动 worker(Celery 职程服务器)

  2.  python manage.py celery beat --loglevel=info # 启动定时任务监听器

  3. celery flower --address=0.0.0.0 --port=5555 # 启动任务监控后台

celery_beat.ini

[root@gitlab conf.d]# cat celery_beat.ini 
[program:CeleryBeat]   
#CelertBeat 为程序的名称
command=/root/.envs/hrm/bin/python manage.py celery beat --loglevel=info
#需要执行的命令
directory=/root/TestProject/HttpRunnerManager
#命令执行的目录
#environment=ASPNETCORE__ENVIRONMENT=Production 
#环境变量
user=root  
#用户
stopsignal=INT 
autostart=true 
#是否自启动
autorestart=true 
#是否自动重启
startsecs=3 
#自动重启时间间隔(s)
stderr_logfile=/root/TestProject/logs/celerybeat.err.log 
#错误日志文件
stdout_logfile=/root/TestProject/logs/celerybeat.out.log 
#输出日志文件

celery_worker.ini

[root@gitlab conf.d]# cat celery_worker.ini 
[program:CeleryWorker]   
#CeleryWork  为程序的名称
command=/root/.envs/hrm/bin/python manage.py celery -A HttpRunnerManager worker --loglevel=info
#需要执行的命令
directory=/root/TestProject/HttpRunnerManager
#命令执行的目录
#environment=ASPNETCORE__ENVIRONMENT=Production 
#环境变量
user=root  
#用户
stopsignal=INT 
autostart=true 
#是否自启动
autorestart=true 
#是否自动重启
startsecs=3 
#自动重启时间间隔(s)
stderr_logfile=/root/TestProject/logs/celeryworker.err.log 
#错误日志文件
stdout_logfile=/root/TestProject/logs/celeryworker.out.log 
#输出日志文件

celery_flower.ini 

[root@gitlab conf.d]# cat celery_flower.ini 
[program:CeleryFlower]   
#CeleryFlower  为程序的名称
command=/root/.envs/hrm/bin/celery flower --address=0.0.0.0 --port=5555
#需要执行的命令
directory=/root/TestProject
#命令执行的目录
#environment=ASPNETCORE__ENVIRONMENT=Production 
#环境变量
user=root  
#用户
stopsignal=INT 
autostart=true 
#是否自启动
autorestart=true 
#是否自动重启
startsecs=3 
#自动重启时间间隔(s)
stderr_logfile=/root/TestProject/logs/celeryflower.err.log 
#错误日志文件
stdout_logfile=/root/TestProject/logs/celeryflower.out.log 
#输出日志文件

supervisorctl 常用命令

supervisorctl  # 进入命令控制台,里面直接敲命令,如:update, start [program]

exit  # 退出 supervisorctl 控制台

supervisorctl reload  # 重启

supervisorctl update  # 更新新的配置到 supervisord

supervisorctl status  # 查看任务状态

supervisorctl start [program]   # 启动指定任务,ini 里面 program 的名称

supervisorctl start all   # 启动全部任务

supervisorctl stop [program]  # 停止指定任务

supervisorctl stop all  # 停止全部任务

supervisorctl restart [program]  # 重启指定任务

supervisorctl restart all  # 重启全部任务

/usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf  # 启动 supervisord,centos7 可以配置 systemctl status supervisord.service

ps -ef | grep supervisor  # 杀进程,找到进程号后 kill -9 进程号


 

 

^_^
请喝咖啡 ×

文章部分资料可能来源于网络,如有侵权请告知删除。谢谢!

前一篇: linux 命令解释
下一篇: windows下,cmd 运行 python 脚本,选中文字就停止运行的解决办法
captcha