使用 supervisor 管理 Celery 服务

安装

> sudo apt-get install supervisor

配置

配置文件可以写 /etc/supervisor/conf.d 下面并且以 .conf 结束。

> sudo mkdir /var/log/celery
> sudo chmod -R 777 /var/log/celery/
> sudo touch /var/log/celery/resource_private_worker.log
> sudo touch /etc/supervisor/conf.d/celery_private.conf

配置可以如下:

[program:celery_private]
command=/home/hdgs/ccnu_resource_private/env/bin/celery -A ccnu_resource worker -l info


directory=/home/hdgs/ccnu_resource_private
user=nobody
numprocs=1
stdout_logfile=/var/log/celery/resource_private_worker.log
stderr_logfile=/var/log/celery/resource_private_worker.log
autostart=true
autorestart=true
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

; Causes supervisor to send the termination signal to the whole process group.
stopasgroup=true

; Set Celery priority higher than default (999)
; so, if rabbitmq is supervised, it will start first.
priority=1000

运行

> sudo supervisorctl reread
> sudo supervisorctl update
> sudo supervisorctl
> sudo supervisorctl stop celery_private
> sudo supervisorctl start celery_private
> sudo supervisorctl restart celery_private

> sudo supervisorctl restart all

状态

> sudo supervisorctl status

猜你喜欢

转载自blog.csdn.net/andybegin/article/details/78971829
今日推荐