dav*_*ode 35 django amazon-ec2 celery supervisord amazon-elastic-beanstalk
我在我的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).
Run Code Online (Sandbox Code Playgroud)
由主管管理的所有流程都正常运行(supervisorctl statusRUNNNING说).
我尝试在ec2实例上读取几个日志,但似乎没有人帮我找出SIGKILL的原因.我该怎么办?我该如何调查?
这些是我的芹菜设置:
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
Run Code Online (Sandbox Code Playgroud)
这是我的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
Run Code Online (Sandbox Code Playgroud)
编辑:重新启动芹菜后击败问题仍然存在:(
编辑2:将killasgroup = true更改为killasgroup = false并且问题仍然存在
Nin*_*ker 43
您的工作人员收到的SIGKILL是由另一个流程发起的.你的supervisord配置看起来很好,而killasgroup只会影响一个主管发起的kill(例如ctl或插件) - 如果没有这个设置,它就会将信号发送给调度员,而不是孩子.
很可能你有内存泄漏,操作系统的oomkiller正在暗杀你的过程中的不良行为.
grep oom /var/log/messages.如果你看到消息,那就是你的问题.
如果找不到任何内容,请尝试在shell中手动运行定期过程:
MyPeriodicTask().run()
看看会发生什么.如果您没有这个主机的仙人掌,神经节等良好的仪器,我会从另一个终端的顶部监控系统和流程指标.
Far*_*dLU 10
当异步任务(通过 celery)或您正在使用的脚本由于泄漏而在内存中存储大量数据时,人们会看到这种错误。
就我而言,我从另一个系统获取数据并将其保存在变量中,因此我可以在完成该过程后导出所有数据(到 Django 模型/Excel 文件中)。
这是问题所在。我的脚本收集了 1000 万个数据;当我收集数据时它正在泄漏内存。这导致了引发的异常。
为了解决这个问题,我将 1000 万条数据分为 20 个部分(每个部分 50 万条)。每次数据长度达到 500,000 条时,我都将数据存储在我自己首选的本地文件/Django 模型中。我对每批 500k 件商品重复此操作。
无需执行确切的分区数量。它是通过将一个复杂问题分解为多个子问题并逐个解决子问题来解决它的思想。:D
| 归档时间: |
|
| 查看次数: |
19615 次 |
| 最近记录: |