supervisor - how to run multiple commands

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I'm managing a Celery worker that processes queue via Supervisor.

Here's my /etc/supervisor/celery.conf:

[program:celery] command = /var/worker/venv/bin/celery worker -A a_report_tasks -Q a_report_process --loglevel=INFO directory=/var/worker user=nobody numprocs=1 autostart=true autorestart=true startsecs=10 stopwaitsecs = 60 stdout_logfile=/var/log/celery/worker.log stderr_logfile=/var/log/celery/worker.log killasgroup=true priority=998 

How do I add this second command to run?

/var/worker/venv/bin/celery worker -A b_report_tasks -Q b_report_process --loglevel=INFO 

I tried separating the two commands on the same line with && (resulted in a syntax error), adding an entirely separate [program:celery] section to this same file (resulted in only the first one being run), and creating an entirely different celery1.conf file in the same directory (resulted in only the original/first one being run).

回答1:

Add a second section with a different task name. If two tasks have the same task name, the latter overwrites the former.

[program:celeryb] command = /var/worker/venv/bin/celery worker -A b_report_tasks -Q b_report_process --loglevel=INFO directory=/var/worker user=nobody numprocs=1 autostart=true autorestart=true startsecs=10 stopwaitsecs = 60 stdout_logfile=/var/log/celery/worker.log stderr_logfile=/var/log/celery/worker.log killasgroup=true priority=998 

You can also group them so both tasks get restarted as a group:

[group:celery-workers] programs=celery,celeryb priority=999 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!