编程语言
首页 > 编程语言> > python – Celery-Supervisor:如何重新启动主管工作以使新更新的芹菜任务正常工作?

python – Celery-Supervisor:如何重新启动主管工作以使新更新的芹菜任务正常工作?

作者:互联网

我的celery服务器有一个正在运行的主管工作.现在我需要向它添加一个新任务,但遗憾的是我的celery服务器命令未配置为自动跟踪这些动态更改.

这是我的芹菜命令:

python manage.py celery worker --broker=amqp://username:password@localhost/our_app_vhost

为了重启我的芹菜过程,我试过了,

sudo supervisorctl -c /etc/supervisor/supervisord.conf restart <process_name>
supervisorctl stop all
supervisorctl start all
service supervisor restart

但没有找到工作.如何重启?

解决方法:

如果要使用supervisorctl管理进程,则应在配置文件中配置supervisorctl,rpcinterface.

这是一个示例配置文件.

sample.conf

[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

[program:my_worker]
command = python manage.py celery worker --broker=amqp://username:password@localhost/our_app_vhost

[unix_http_server]
file=/tmp/supervisor.sock   ; (the path to the socket file)

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

现在开始主管

supervisord -c sample.conf

现在,如果您想重新启动您的工作人员,您可以使用它

supervisorctl -c sample.conf restart my_worker

这会重新启动您的工作人员或者,您也可以转到supervisor shell,然后重新启动它

sudo supervisorctl -c sample.conf
supervisor> restart my_worker
my_worker: stopped
my_worker: started

注意:

可以选择在Celery中自动重载工作程序

python manage.py celery worker --autoreload --broker=amqp://username:password@localhost/our_app_vhost

这应该仅在开发模式中使用.不建议在生产中使用它.

关于celery docs的更多相关信息.

标签:supervisor,python,django,celery,django-celery
来源: https://codeday.me/bug/20190722/1505864.html