主管-如何运行多个命令 [英] supervisor - how to run multiple commands
问题描述
我正在管理一个通过Supervisor处理队列的芹菜工人。
I'm managing a Celery worker that processes queue via Supervisor.
这是我的/etc/supervisor/celery.conf:
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
我尝试用&&
分隔同一行中的两个命令(导致语法错误),添加了一个完全将 [program:celery]
部分分开到同一文件(仅导致第一个),并在同一目录中创建一个完全不同的 celery1.conf
文件(仅导致运行的是原始文件/第一个文件)。
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).
推荐答案
添加另一个带有不同任务名称的部分。如果两个任务具有相同的任务名称,则后者将覆盖前一个任务。
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
这篇关于主管-如何运行多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!