芹菜不会重新启动子流程

时间:2015-07-24 12:18:49

标签: celery supervisord

我有芹菜部署的问题 - 当我重新启动它时,旧的子流程不会停止并继续处理一些工作。我用supervisord来运行芹菜。这是我的配置:

$ cat /etc/supervisor/conf.d/celery.conf 
[program:celery]
; Full path to use virtualenv, honcho to load .env
command=/home/ubuntu/venv/bin/honcho run celery -A stargeo worker -l info --no-color

directory=/home/ubuntu/app
environment=PATH="/home/ubuntu/venv/bin:%(ENV_PATH)s"
user=ubuntu
numprocs=1
stdout_logfile=/home/ubuntu/logs/celery.log
stderr_logfile=/home/ubuntu/logs/celery.err
autostart=true
autorestart=true
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998

芹菜过程的外观如下:

$ ps axwu | grep celery
ubuntu     983  0.0  0.1  47692 10064 ?        S    11:47   0:00 /home/ubuntu/venv/bin/python /home/ubuntu/venv/bin/honcho run celery -A stargeo worker -l info --no-color
ubuntu     984  0.0  0.0   4440   652 ?        S    11:47   0:00 /bin/sh -c celery -A stargeo worker -l info --no-color
ubuntu     985  0.0  0.5 168720 41356 ?        S    11:47   0:01 /home/ubuntu/venv/bin/python /home/ubuntu/venv/bin/celery -A stargeo worker -l info --no-color
ubuntu     990  0.0  0.4 167936 36648 ?        S    11:47   0:00 /home/ubuntu/venv/bin/python /home/ubuntu/venv/bin/celery -A stargeo worker -l info --no-color
ubuntu     991  0.0  0.4 167936 36648 ?        S    11:47   0:00 /home/ubuntu/venv/bin/python /home/ubuntu/venv/bin/celery -A stargeo worker -l info --no-color

当我运行sudo supervisorctl restart celery时,它只会停止第一个进程python ... honcho,其他所有进程都会继续。如果我试图杀死他们,他们会继续(kill -9工作)。

1 个答案:

答案 0 :(得分:0)

这似乎是a bug with honcho。我最终解决了从主管开始这个脚本的问题:

#!/bin/bash

source /home/ubuntu/venv/bin/activate
exec env $(cat .env | grep -v ^# | xargs) \
     celery -A stargeo worker -l info --no-color