[英]How can I automatically reload tasks modules with Celery daemon?
我正在使用Fabric部署一個Celery代理(運行RabbitMQ)和多個Celery工人,並通過supervisor
celeryd
celeryd。 我一輩子都無法弄清楚如何在不重新啟動服務器的情況下重新加載tasks.py
模塊。
/etc/supervisor/conf.d/celeryd.conf
[program:celeryd]
directory=/fab-mrv/celeryd
environment=[RABBITMQ crendentials here]
command=xvfb-run celeryd --loglevel=INFO --autoreload
autostart=true
autorestart=true
celeryconfig.py
import os
## Broker settings
BROKER_URL = "amqp://%s:%s@hostname" % (os.environ["RMQU"], os.environ["RMQP"])
# List of modules to import when celery starts.
CELERY_IMPORTS = ("tasks", )
## Using the database to store task state and results.
CELERY_RESULT_BACKEND = "amqp"
CELERYD_POOL_RESTARTS = True
附加信息
celery --version
3.0.19(幻燈片) python --version
2.7.3 lsb_release -a
Ubuntu 12.04.2 LTS rabbitmqctl status
... 2.7.1 ... 這是我嘗試過的一些方法:
celeryd --autoreload
標志 sudo supervisorctl restart celeryd
celery.control.broadcast('pool_restart', arguments={'reload': True})
ps auxww | grep celeryd | grep -v grep | awk '{print $2}' | xargs kill -HUP
不幸的是,沒有任何原因導致工作人員重新加載task.py模塊(例如,在運行git pull
更新文件之后)。 有關晶圓廠功能的要點,請點擊此處 。
重新啟動后,代理/工作人員運行良好。
只是使用celeryd --autoreload
選項在黑暗中拍攝,您確定您擁有一個文件系統通知后端嗎? 它推薦用於Linux的PyNotify,因此我首先要確保已安裝了該軟件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.