简体   繁体   English

主管 - 如何运行多个命令

[英]supervisor - how to run multiple commands

I'm managing a Celery worker that processes queue via Supervisor. 我正在管理一个通过Supervisor处理队列的Celery工作者。

Here's my /etc/supervisor/celery.conf: 这是我的/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). 我尝试用&&分隔同一行上的两个命令(导致语法错误),在同一个文件中添加一个完全独立的[program:celery]部分(导致只运行第一个),并创建一个完全不同的celery1.conf文件位于同一目录中(仅导致原始/第一个正在运行)。

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

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

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