1. 使用systemd控制Celery

用法: systemctl {start|stop|restart|status} celery.service

配置文件: /etc/celery/celery.conf

celery服务文件: /etc/systemd/system/celery.service

celery beat服务文件: /etc/systemd/system/celerybeat.service

服务文件: /etc/systemd/system/celery.service

[Unit]
Description=Celery Service
After=network.target [Service]
Type=forking
User=celery
Group=celery
EnvironmentFile=/etc/celery/celery.conf
WorkingDirectory=/app/celery
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
--pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES} \
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}' [Install]
WantedBy=multi-user.target

应用的配置文件: /etc/celery/celery.conf

# Name of nodes to start
# here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3" # Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/local/python3.6.5/bin/celery" # App instance to use
# comment out this line if you don't use an app
CELERY_APP="tasks"
# or fully qualified:
#CELERY_APP="proj.tasks:app" # How to call manage.py
CELERYD_MULTI="multi" # Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8" # - %n will be replaced with the first part of the nodename.
# - %I will be replaced with the current child process index
# and is important when using the prefork pool to avoid race conditions.
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_LOG_LEVEL="INFO" # you may wish to add these options for Celery Beat
CELERYBEAT_PID_FILE="/var/run/celery/beat.pid"
CELERYBEAT_LOG_FILE="/var/log/celery/beat.log"

Celery Beat服务文件:celerybeat.service

这是Celery Beat的示例systemd文件:

/etc/systemd/system/celerybeat.service

[Unit]
Description=Celery Beat Service
After=network.target [Service]
Type=simple
User=celery
Group=celery
EnvironmentFile=/etc/celery/celery.conf
WorkingDirectory=/opt/celery
ExecStart=/bin/sh -c '${CELERY_BIN} beat \
-A ${CELERY_APP} --pidfile=${CELERYBEAT_PID_FILE} \
--logfile=${CELERYBEAT_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL}' [Install]
WantedBy=multi-user.target

最新文章

  1. 虚拟机安装windows服务出现无法打开内核设备“\\.Global\vmx86”
  2. [django]Django站点admin支持中文显示和输入设置
  3. Nginx+Tomcat构建动、静分离WEB架构
  4. java 并发性和多线程 -- 读感 (二 线程间通讯,共享内存的机制)
  5. eclipse安装JAVA反编译插件
  6. Java-->多线程复制(文件指针)
  7. 自定义cell 自适应高度
  8. C#用Open与Add方法打开word文档的区别
  9. Clion快捷键
  10. [Hinton] Neural Networks for Machine Learning - Hopfield Nets and Boltzmann Machine
  11. ansible debug模块学习笔记
  12. docker 数据卷 ---- 进阶篇
  13. Linux下onvif客户端获取ipc摄像头 GetProfiles:获取h265媒体信息文件
  14. python实战===一键刷屏
  15. AndroidManifest.xml文件详解(application)
  16. tmux颜色高亮跟vim不一致的情况
  17. QString, Std::string, char *相互转换
  18. MySQL Index Condition Pushdown 原理与解析
  19. [Silverlight]调用外部可执行程序
  20. ApplicationContext的三个常用实现类:

热门文章

  1. Twitter Storm学习笔记
  2. 项目Beta冲刺(团队) ——随笔集合
  3. wraps装饰器的作用
  4. Python错误 -- try/except/finally 、调用栈、记录错误、抛出错误
  5. cogs 998. [東方S2] 帕秋莉·诺蕾姬
  6. windows自动修复失败,无法启动
  7. GoCN每日新闻(2019-10-28)
  8. mongo helper
  9. WordPress入门 之 设置导航菜单
  10. Java NIO 文件通道使用