首页 > 其他 > 详细

centos将celery写入系统服务

时间:2019-07-19 11:32:03      阅读:123      评论:0      收藏:0      [点我收藏+]
第一步:
在/etc/下创建目录 celery/celery.conf
代码如下:
CELERYD_NODES=‘w1 w2 w3‘   # 启动的celery进程的进程名
CELERY_BIN=‘/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/celery‘
CELERY_APP=‘Fresh‘
CELERYD_MULTI=‘multi‘
CELERYD_OPTS=‘--time-limit=300 --concurrency=1‘

CELERYD_PID_FILE=‘/var/run/celery/%n.pid‘
CELERYD_LOG_FILE=‘/var/log/celery/%n%I.log‘
CELERYD_LOG_LEVEL=‘INFO‘

 

第二步: /etc/systemd/system/目录下,创建 celery.service
代码如下:

[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=root
#Group=celery
EnvironmentFile=/etc/celery/celery.conf
WorkingDirectory=/root/Work/DailyFresh/Day_fresh/Fresh
ExecStart=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/celery multi start -A Fresh worker -l info
logfile=/root/Work/DailyFresh/Day_fresh/logs/celerylog.log
ExecStop=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/celery multi stop -A Fresh worker -l info
logfile=/root/Work/DailyFresh/Day_fresh/logs/celerylog.log
ExecReload=/root/.local/share/virtualenvs/Day_fresh-KKzeP8YR/bin/celery multi restart work -A Fresh worker -l info
logfile=/root/Work/DailyFresh/Day_fresh/logs/celerylog.log
[Install]
WantedBy=multi-user.target

 使用systemd运行celery.service

重载配置文件
每次修改celery.service配置后都要执行此命令,以便systemd确认该文件
systemctl daemon-reload
启动命令
systemctl start celery.service
停止命令
systemctl stop celery.service
重启命令
systemctl restart celery.service
查看celery.service的运行状态
systemctl status celery.service

centos将celery写入系统服务

原文:https://www.cnblogs.com/wangyue0925/p/11211752.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!