【发布时间】:2014-05-13 08:38:31
【问题描述】:
我在我的 Django 应用程序(在 Elastic Beanstalk 上)中使用 Celery 和 RabbitMQ 来管理后台任务,并使用 Supervisor 对其进行守护。 现在的问题是,我定义的周期任务之一失败(在它正常工作一周后),我得到的错误是:
[01/Apr/2014 23:04:03] [ERROR] [celery.worker.job:272] Task clean-dead-sessions[1bfb5a0a-7914-4623-8b5b-35fc68443d2e] raised unexpected: WorkerLostError('Worker exited prematurely: signal 9 (SIGKILL).',)
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python2.7/site-packages/billiard/pool.py", line 1168, in mark_as_worker_lost
human_status(exitcode)),
WorkerLostError: Worker exited prematurely: signal 9 (SIGKILL).
主管管理的所有进程都已启动并正常运行(supervisorctl status 表示 RUNNNING)。
我试图阅读我的 ec2 实例上的几份日志,但似乎没有人帮助我找出导致 SIGKILL 的原因。我该怎么办?我该如何调查?
这些是我的celery 设置:
CELERY_TIMEZONE = 'UTC'
CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['json']
BROKER_URL = os.environ['RABBITMQ_URL']
CELERY_IGNORE_RESULT = True
CELERY_DISABLE_RATE_LIMITS = False
CELERYD_HIJACK_ROOT_LOGGER = False
这是我的 supervisord.conf:
[program:celery_worker]
environment=$env_variables
directory=/opt/python/current/app
command=/opt/python/run/venv/bin/celery worker -A com.cygora -l info --pidfile=/opt/python/run/celery_worker.pid
startsecs=10
stopwaitsecs=60
stopasgroup=true
killasgroup=true
autostart=true
autorestart=true
stdout_logfile=/opt/python/log/celery_worker.stdout.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=10
stderr_logfile=/opt/python/log/celery_worker.stderr.log
stderr_logfile_maxbytes=5MB
stderr_logfile_backups=10
numprocs=1
[program:celery_beat]
environment=$env_variables
directory=/opt/python/current/app
command=/opt/python/run/venv/bin/celery beat -A com.cygora -l info --pidfile=/opt/python/run/celery_beat.pid --schedule=/opt/python/run/celery_beat_schedule
startsecs=10
stopwaitsecs=300
stopasgroup=true
killasgroup=true
autostart=false
autorestart=true
stdout_logfile=/opt/python/log/celery_beat.stdout.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=10
stderr_logfile=/opt/python/log/celery_beat.stderr.log
stderr_logfile_maxbytes=5MB
stderr_logfile_backups=10
numprocs=1
编辑 1
重启celery beat后问题依旧。
编辑 2
将killasgroup=true更改为killasgroup=false,问题依旧。
【问题讨论】:
-
提示:很可能是因为您的服务器内存/内存不足。如果你通过 docker 命令运行容器,你可以使用
docker stats查看每个容器的内存消耗。
标签: django amazon-ec2 celery amazon-elastic-beanstalk supervisord