參考文章:https://thomassileo.name/blog/2012/08/20/how-to-keep-celery-running-with-supervisor/
使用 supervisord
安裝 supervisord
pip install supervisor
cd 我的django項目目錄
echo_supervisord_conf> supervisord.conf # 創建配置文件,這個配置文件要放在django的根路徑下
這裏我生成的 supervisord.conf 文件路徑
編輯 supervisord.conf 文件,在最後添加下面內容
[program:celeryd]
command=/root/.virtualenvs/python_company/bin/celery -A test_project worker -P eventlet --loglevel=INFO --concurrency=15
stdout_logfile=/var/log/celery/celeryd.log
stderr_logfile=/var/log/celery/celeryd.log
autostart=true
autorestart=true
startsecs=10
command : 你要執行的 celery 命令, autostart :自啓
啓動supervisord
supervisord
成功啓動後,我的日誌文件裏面的內容如下, 只要沒有報錯信息,就是成功的