【问题标题】:Save Celery tasks to database for monitor in Django admin将 Celery 任务保存到数据库以在 Django admin 中进行监控
【发布时间】:2016-05-07 16:22:12
【问题描述】:

我成功设置了 Celery 3.1 + Django 1.6 + Djcelery,任务正在运行,一切都很好。在 Django 管理界面中,我看到带有选项的 Djcelery 菜单,但在 Tasks 选项卡上看不到任何任务,在 Workers 选项卡上没有工作人员。

如何配置让它们自动存储状态?

我的设置.py:

    # Celery settings

#BROKER_URL = 'amqp://guest:guest@localhost//'
BROKER_URL = 'django://'

from kombu.serialization import registry
registry.enable('pickle')

#: Only add pickle to this list if your broker is secured
#: from unwanted access (see userguide/security.html)
CELERY_ACCEPT_CONTENT = ['json', 'pickle']
CELERY_TASK_RESULT_EXPIRES=3600
#CELERY_RESULT_BACKEND='amqp'
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
# postgresql
#CELERY_RESULT_BACKEND = 'db+postgresql://postgres:111222@localhost/graphgrail'
#CELERY_RESULT_BACKEND='djcelery.backends.cache:CacheBackend',
CELERY_RESULT_SERIALIZER = 'json' #json pickle msgpack
CELERY_TASK_SERIALIZER = 'json'
CELERY_IMPORTS=["vk_wall.tasks"]

【问题讨论】:

    标签: python django celery


    【解决方案1】:

    你需要celerycam

    在您的 uwsgi.ini 中(如果您使用它进行部署),您需要这一行:

    attach-daemon = /path/to/your/virtualenv/bin/python /var/www/yoursite/manage.py celerycam 
    

    【讨论】:

    • 在本地主机上运行 python manage.py celerycam,cam 启动,任务工作,但在管理面板中没有任何内容,你能告诉我把 attach-daemon = string 放在哪里吗?
    猜你喜欢
    • 2016-03-31
    • 2016-11-22
    • 2014-03-16
    • 2015-09-07
    • 2021-02-19
    • 1970-01-01
    • 2017-12-21
    • 2013-05-14
    • 1970-01-01
    相关资源
    最近更新 更多