【问题标题】:Celery doesn't restart subprocesses芹菜不会重新启动子进程
【发布时间】:2015-07-24 12:18:49
【问题描述】:

我在部署 celery 时遇到问题 - 当我重新启动它时,旧的子进程不会停止并继续处理一些作业。我使用 supervisord 来运行 celery。这是我的配置:

$ 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

这是 celery 进程的样子:

$ 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 有效)。

【问题讨论】:

    标签: celery supervisord


    【解决方案1】:

    这似乎是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
    

    【讨论】:

      猜你喜欢
      • 2018-05-23
      • 2016-06-22
      • 1970-01-01
      • 2014-12-06
      • 2023-03-16
      • 2019-01-31
      • 2016-08-22
      • 2021-08-22
      • 2013-01-09
      相关资源
      最近更新 更多