如何配置celery在Nginx启动时运行? [英] How can I configure celery to run on startup of nginx?

查看:304
本文介绍了如何配置celery在Nginx启动时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是通过运行celery -A proj -l info在本地运行celery(尽管我什至不知道我是否应该在生产中使用此命令),并且我希望每次nginx启动时都能在生产Web服务器上运行celery.初始化系统为systemd

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

推荐答案

创建这样的服务文件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

将文件移动到/etc/systemd/system/,下次重启服务器时,celery将由systemd在启动时启动.

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

这篇关于如何配置celery在Nginx启动时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆