Celeryd多用supervisord

gog*_*sca 3 python celery supervisord celeryd

尝试用芹菜多来运行supervisord(3.2.2).

似乎是supervisord无法处理它.单个芹菜工人工作正常.

这是我的supervisord配置

celery multi v3.1.20 (Cipater)
> Starting nodes...
    > celery1@parzee-dev-app-sfo1: OK
Stale pidfile exists. Removing it.
    > celery2@parzee-dev-app-sfo1: OK
Stale pidfile exists. Removing it.
Run Code Online (Sandbox Code Playgroud)

celeryd.conf

; ==================================
;  celery worker supervisor example
; ==================================

[program:celery]
; Set full path to celery program if using virtualenv
command=/usr/local/src/imbue/application/imbue/supervisorctl/celeryd/celeryd.sh
process_name = %(program_name)s%(process_num)d@%(host_node_name)s
directory=/usr/local/src/imbue/application/imbue/conf/
numprocs=2
stderr_logfile=/usr/local/src/imbue/application/imbue/log/celeryd.err
logfile=/usr/local/src/imbue/application/imbue/log/celeryd.log
stdout_logfile_backups = 10
stderr_logfile_backups = 10
stdout_logfile_maxbytes = 50MB
stderr_logfile_maxbytes = 50MB
autostart=true
autorestart=false
startsecs=10
Run Code Online (Sandbox Code Playgroud)

我使用以下supervisord变量来模仿我开始芹菜的方式:

  • %(程序名)类
  • %(process_num)d
  • @
  • %(host_node_name)类

Supervisorctl

supervisorctl 
celery:celery1@parzee-dev-app-sfo1   FATAL     Exited too quickly (process log may have details)
celery:celery2@parzee-dev-app-sfo1   FATAL     Exited too quickly (process log may have details)
Run Code Online (Sandbox Code Playgroud)

我尝试在/中更改此值usr/local/lib/python2.7/dist-packages/supervisor/options.py from 0 to 1:

numprocs_start = integer(get(section, 'numprocs_start', 1))
Run Code Online (Sandbox Code Playgroud)

我还是得到:

celery:celery1@parzee-dev-app-sfo1   FATAL     Exited too quickly (process log may have details)
celery:celery2@parzee-dev-app-sfo1   EXITED    May 14 12:47 AM
Run Code Online (Sandbox Code Playgroud)

Celery正在开始,但是supervisord没有跟踪它.

根@ parzee-DEV-APP-SFO1:在/ etc /主管#

ps -ef | grep celery
root      2728     1  1 00:46 ?        00:00:02 [celeryd: celery1@parzee-dev-app-sfo1:MainProcess] -active- (worker -c 16 -n celery1@parzee-dev-app-sfo1 --loglevel=DEBUG -P processes --logfile=/usr/local/src/imbue/application/imbue/log/celeryd.log --pidfile=/usr/local/src/imbue/application/imbue/log/1.pid)
root      2973     1  1 00:46 ?        00:00:02 [celeryd: celery2@parzee-dev-app-sfo1:MainProcess] -active- (worker -c 16 -n celery2@parzee-dev-app-sfo1 --loglevel=DEBUG -P processes --logfile=/usr/local/src/imbue/application/imbue/log/celeryd.log --pidfile=/usr/local/src/imbue/application/imbue/log/2.pid)
Run Code Online (Sandbox Code Playgroud)

celery.sh

source ~/.profile
CELERY_LOGFILE=/usr/local/src/imbue/application/imbue/log/celeryd.log
CELERYD_OPTS=" --loglevel=DEBUG"
CELERY_WORKERS=2
CELERY_PROCESSES=16
cd /usr/local/src/imbue/application/imbue/conf
exec celery multi start $CELERY_WORKERS -P processes -c $CELERY_PROCESSES -n celeryd@{HOSTNAME} -f $CELERY_LOGFILE $CELERYD_OPTS
Run Code Online (Sandbox Code Playgroud)

类似: 与主管 一起运行celeryd_multi 如何使用Supervisor + Django + Celery与多个队列和工作人员?

Chi*_*and 14

由于管理程序监视(启动/停止/重新启动)进程,因此该进程应在​​前台运行(不应该进行守护程序).

Celery multi daemonizes自己,所以它不能与主管一起运行.

您可以为每个工作人员创建单独的流程并将其分组.

[program:worker1]
command=celery worker -l info -n worker1

[program:worker2]
command=celery worker -l info -n worker2

[group:workers]
programs=worker1,worker2
Run Code Online (Sandbox Code Playgroud)

您还可以编写一个shell脚本,使守护程序进程像这样在前台运行.

#! /usr/bin/env bash
set -eu

pidfile="/var/run/your-daemon.pid"
command=/usr/sbin/your-daemon

# Proxy signals
function kill_app(){
    kill $(cat $pidfile)
    exit 0 # exit okay
}
trap "kill_app" SIGINT SIGTERM

# Launch daemon
$ celery multi start 2 -l INFO

sleep 2

# Loop while the pidfile and the process exist
while [ -f $pidfile ] && kill -0 $(cat $pidfile) ; do
    sleep 0.5
done
exit 1000 # exit unexpected
Run Code Online (Sandbox Code Playgroud)