How can I configure celery to run on startup of nginx?

爷,独闯天下 提交于 2019-12-13 04:05:08

问题


I have celery running locally by just running celery -A proj -l info (although I don't even know if I should be using this command in production), and I want to get celery running on my production web server every time nginx starts. The init system is systemd


回答1:


Create a service file like this celery.service

[Unit]
Description=celery service
After=network.target

[Service]
PIDFile=/run/celery/pid
User=celery
Group=celery
RuntimeDirectory=/path/to/project
WorkingDirectory=/path/to/project
ExecStart=celery -A proj -l info
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=on-abort
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Move the file to /etc/systemd/system/ and next time your restart server, celery will be started by systemd on boot.



来源:https://stackoverflow.com/questions/49377865/how-can-i-configure-celery-to-run-on-startup-of-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!