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,查看是否运行正常。