1.安裝supervisor,celery
都是python包,直接pip install 相應的包就可以
2.vim /etc/supervisord.conf ,增加如下配置
[program:celery]
command=/data/webserver/chat-bot-django/py3env/bin/python -u manage.py celery worker -B -l info
directory=/data/webserver/chat-bot-django
stdout_logfile=/var/log/celery/info.log
autostart=true
stderr_logfile=/var/log/celery/err.log
autorestart=true
redirect_stderr=true
stopsignal=QUIT
其中command,我這邊是用的virtualenv下面的,自己看自己的情況處理
python manager.py celery worker -B -l info
worker:啓動celery broker
-B: 啓動celery beat,該進程在定時到達時會自動向broker中加一條任務
-l info:啓動celery日誌
directory,指的是django項目根目錄
其他配置看字面意思理解
3.重啓supervisord, /etc/init.d/supervisord restart
進入supervisorctl,查看是否運行正常。