【发布时间】:2017-01-16 19:39:24
【问题描述】:
在supervisor 下,celery beat 为我的 Django 应用程序的 celery 工人提供定期任务。我有 4 个任务,task1、task2、task3 和 task4。最近我做了第五个任务:task5。
我的问题是我从我的工作人员中注释掉了task5,从 settings.py 中删除了它的提及并重新启动了 celerybeat 和我的 celery 工作人员。但我仍然看到task5 定期出现(自然会在工作人员的日志中抛出错误)。
为什么会发生这种情况,如何更新定期任务?
在 settings.py 中,我有:
import djcelery
djcelery.setup_loader()
# config settings for Celery Daemon
# Redis broker
BROKER_URL = 'redis://localhost:6379/0'
BROKER_TRANSPORT = 'redis'
# List of modules to import when celery starts, in myapp.tasks form.
CELERY_IMPORTS = ('myapp.tasks', )
CELERY_ALWAYS_EAGER = False
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
#The backend is the resource which returns the results of a completed task from Celery. 6379 is the default port to the redis server.
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT=True
from datetime import timedelta
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERYBEAT_SCHEDULE = {
'tasks.task1': {
'task': 'tasks.task1',
'schedule': timedelta(seconds=45),
},
'tasks.task2': {
'task': 'tasks.task2',
'schedule': timedelta(seconds=60), # execute every 60 seconds
'args': (),
},
'tasks.task3': {
'task': 'tasks.task3',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
'tasks.task4': {
'task': 'tasks.task4',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
}
/etc/supervisor/conf.d/celerybeat.conf 包含以下内容:
command=python manage.py celery beat -l info
directory = /home/myuser/myproject/
environment=PATH="/home/myuser/envs/myenv/bin",VIRTUAL_ENV="/home/myuser/envs/myenv",PYTHONPATH="/home/myuser/envs/myenv/lib/python2.7:/home/myuser/envs/myenv/lib/python2.7/site-packages"
user=mhb11
numprocs=1
stdout_logfile = /etc/supervisor/logs/celerybeat.log
stderr_logfile = /etc/supervisor/logs/celerybeat.log
autostart = true
autorestart = true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=999
如果您需要,请向我询问更多信息。提前致谢。
【问题讨论】:
标签: django celery supervisord celery-task celerybeat