从Supervisor停止Celery worker时的WorkerLostError

问题描述 投票:3回答:1

每当我在Supervisor中运行“stop celery-worker”来阻止我的Celery工作时,我都会遇到以下错误:

625[2014-05-18 14:41:59,650: ERROR/MainProcess] Task tasks.send_process_my_task[2ff51473-80f9-4c53-9b9a-b8ddc8c36618] raised unexpected: WorkerLostError('Worker exited prematurely: signal 15 (SIGTERM).',)  
626Traceback (most recent call last):                                                                                                                                                                              
627  File "/usr/local/envs/mylocalenv/local/lib/python2.7/site-packages/billiard/pool.py", line 1168, in mark_as_worker_lost                                                                                        
628    human_status(exitcode)),                                                                                                                                                                                    
629WorkerLostError: Worker exited prematurely: signal 15 (SIGTERM).                                                                                                                   
630[2014-05-18 14:41:59,653: ERROR/MainProcess] Process 'Worker-4' pid:2279 exited with exitcode -15                                                                                             
631[2014-05-18 14:41:59,683: ERROR/MainProcess] Task tasks.send_process_my_task[9847bda0-9073-4b66-872f-ab4ed18b8690] raised unexpected: WorkerLostError('Worker exited prematurely: signal 15 (SIGTERM).',) 

但是,如果我使用Ctrl-C将工作人员停在前台,则工作人员会正常关闭而不会出现任何错误:

[2014-05-18 14:53:39,124: DEBUG/MainProcess] | Worker: Stopping Pool...
190[2014-05-18 14:53:46,769: INFO/MainProcess] Task tasks.send_process_my_task[8071162a-b47a-4aa4-94e7-72f51443b411] succeeded in 16.467172019s: u''
191[2014-05-18 14:53:46,816: INFO/MainProcess] Task tasks.send_process_my_task[1dd4cb3c-322c-41a3-94ea-f0dde604e6d3] succeeded in 16.389319943s: u''
192[2014-05-18 14:53:46,817: INFO/MainProcess] Task tasks.send_process_my_task[5e72e357-352b-47aa-9dda-51da53220a5e] succeeded in 16.424921152s: u''
193[2014-05-18 14:53:48,903: INFO/MainProcess] Task tasks.send_process_my_task[30c1064a-0f04-49e2-9282-a6031e97a448] succeeded in 18.595272409s: u''

主管中是否有任何可能导致杀害工人的事情?我希望主管发送一个sigterm信号,不要杀死进程。

这是我的芹菜主管配置的副本:

[program:celery-worker]
command=/path/to/script-running-celery.sh
directory=/path/to/celery/project/tasks
user=myuser
stdout_logfile=/var/log/celery/worker.log
stderr_logfile=/var/log/celery/worker.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 1200
killasgroup=true
stopasgroup=true
priority=50

从主管(运行芹菜)执行的脚本:

#!/bin/bash

export PATH="$PATH:/mylocal-envs/localenv";
cd /path/to/celery/project/tasks;
exec /mylocal-envs/localenv/bin/celery worker -c8 -n my_worker_%h_$(uuid) --without-gossip -A tasks --queues=myqueue --loglevel=INFO -Ofair

谢谢你的帮助,

celery supervisord supervisor
1个回答
0
投票

我发现如果将stopsignal选项更改为INT而不是默认的TERM,则工作人员会优雅地关闭,因为在终端中运行芹菜时从前台定期热关闭。

© www.soinside.com 2019 - 2024. All rights reserved.