简体   繁体   English

如何重启Celery Wroker由Supervisord运行

[英]How to Restart Celery Wroker ran by Supervisord

I am running celery on production using supervisord. 我正在使用supervisord生产芹菜。 My supervisor configuration is below. 我的主管配置如下。

[program:celeryd]
command=%(ENV_PROJECT_PATH)s/scripts/celery_worker.sh
stdout_logfile=%(ENV_PROJECT_PATH)s/celeryd.log
stderr_logfile=%(ENV_PROJECT_PATH)s/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=1000
priority=1000

My command to run celery worker is 我操作芹菜工人的命令是

celery_path=$(which celery)
$celery_path -A Project_Name worker --loglevel=info

I want to ask, how to restart celery worker when my codebase changes in production? 我想问一下,当我的代码库在生产中发生变化时,如何重新启动芹菜工作者?

Add following in supervisor file and restart supervisor. 在管理程序文件中添加以下内容并重新启动主管。

killasgroup=true killasgroup =真

The main issue I run into is that long running tasks may get killed if you tell supervisor to killasgroup which would result in lost data. 我遇到的主要问题是,如果告诉主管killasgroup会导致数据丢失,长时间运行的任务可能会被杀死。

The solution I've moved to using is to tell the mainprocess to TERM which will kill off the workers as they finish their tasks. 我转而使用的解决方案是将主进程告诉TERM,它将在完成任务时杀掉工作人员。 supervisor will then restart the main process after all the workers finish. 在所有工人完成后,主管将重新启动主要流程。

ps aux | grep celery.*MainProcess | awk '{print $2}' | xargs kill -TERM

This is also related. 这也是相关的。 Celery Production Graceful Restart 芹菜生产优雅重启

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM