一、前言

本教程重点在于supervisor的配置过程,celery的安装配置请参考其他教程

二、安装supervisor

1.安装命令

pip install supervisor # supervisor目前只支持python2,但是作为容器来说,并不影响监控程序是python3的程序

2.执行 配置文件 生成命令

echo_supervisord_conf > /etc/supervisord.conf

3.创建配置文件需要的文件夹

  1. mkdir /var/log/celery/
  2. mkdir /var/log/celery/
  3. mkdir /var/log/supervisor/
  4. mkdir /var/run/supervisor/

4.更改权限

  1. mkdir /var/log/celery/
  2. mkdir /var/log/celery/
  3. mkdir /var/log/supervisor/
  4. mkdir /var/run/supervisor/

5.编辑配置文件 /etc/supervisord.conf 加入celery配置项(本配置中没使用beat)

  1. ; ==================================
  2. ; celery worker supervisor example
  3. ; ==================================
  4.  
  5. [program:celery]
  6. ; 如果使用的是虚拟环境(virtualenv等)要把celery命令路径写全
  7. command=/home/hiveme/env/cznews/bin/celery worker -A cznews --loglevel=INFO
  8.  
  9. ; Alternatively,
  10. ;command=celery --app=your_app.celery:app worker --loglevel=INFO -n worker.%%h
  11. ; Or run a script
  12. ;command=celery.sh
  13.  
  14. directory=/home/hiveme/cznews/ ;项目所在目录
  15. user=nobody
  16. numprocs=1
  17. stdout_logfile=/var/log/celery/worker.log ;celery输出日志文件
  18. stderr_logfile=/var/log/celery/workererr.log ;celery错误输出文件
  19. autostart=true
  20. autorestart=true
  21. startsecs=10
  22.  
  23. ; Need to wait for currently executing tasks to finish at shutdown.
  24. ; Increase this if you have very long running tasks.
  25. stopwaitsecs = 600
  26.  
  27. ; Causes supervisor to send the termination signal (SIGTERM) to the whole process group.
  28. stopasgroup=true
  29.  
  30. ; Set Celery priority higher than default (999)
  31. ; so, if rabbitmq is supervised, it will start first.
  32. priority=1000
  33.  
  34. ; ================================
  35. ; celery beat supervisor example
  36. ; ================================
  37.  
  38. ;[program:celerybeat]
  39. ; Set full path to celery program if using virtualenv
  40. ;command=/home/hiveme/env/cznews/bin/celery beat --schedule /var/lib/celery/beat.db --loglevel=INFO
  41. ;command=celery beat -A myapp --schedule /var/lib/celery/beat.db --loglevel=INFO ;the ordinary
  42.  
  43. ; remove the -A myapp argument if you aren't using an app instance
  44.  
  45. ;directory=/home/hiveme/cznews/
  46. ;user=nobody
  47. ;numprocs=1
  48. ;stdout_logfile=/var/log/celery/beat.log
  49. ;stderr_logfile=/var/log/celery/beaterr.log
  50. ;autostart=true
  51. ;autorestart=true
  52. ;startsecs=10
  53.  
  54. ; Causes supervisor to send the termination signal (SIGTERM) to the whole process group.
  55. ;stopasgroup=true
  56.  
  57. ; if rabbitmq is supervised, set its priority higher
  58. ; so it starts first
  59. ;priority=999

三、启动supervisor(需要使用root权限)

supervisord -c /etc/supervisord.conf

四、启动过程中的问题(查看supervisord.log和celery的错误日志)

注意重启服务器

1.INFO spawnerr: can't find command 'celery'(supervisord.log)

解决方案:

检查 celery是否安装在虚拟环境中,如果是在配置文件中 需要把所有celery的命令改成 完整的路径



2.INFO spawnerr: unknown error making dispatchers for 'celery': EACCES(supervisord.log)

主要是没有权限操作日志文件

解决方案:

chown youruser:youruser -R /var/log/supervisor/

chown youruser:youruser -R /var/run/supervisor/

chown youruser:youruser -R /var/log/celery/

chown youruser:youruser -R /var/log/celery/



3.exited: celery (exit status 127; not expected)(supervisord.log)

这日志报错,网上是说127是指命令不合法

但是当把命令单独拿到外面执行时也可以执行,进入celery日志查看后发现如下错误:

supervisor: couldn't setuid to 65534: Can't drop privilege as nonroot usersupervisor: child process was not spawned

还是说权限问题,

解决方案:

目前是通过root运行解决的,有更好办法的小伙伴可以和大家一起交流交流

4.supervisorctl: error: <class 'socket.error'>, [Errno 101] Network is unreachable: file: /data/openfalcon/open-falcon/python/lib/python2.7/socket.py line: 575

解决方案

运行supervisorctl时指定配置文件才可以正常运行supervisorctl,否则supervisorctl默认去/etc/supervisord.conf去读取配置,导致错误。

supervisorctl -c your/path/to/your/conf

supervisor 启动 celery 及启动中的问题的更多相关文章

  1. celery无法启动的问题 SyntaxError: invalid syntax

    遇到了celery无法启动的问题,报错:SyntaxError: invalid syntax ,这是因为我使用的python版本为最新3.7.3 ,而async已经作为关键字而存在了 在 celer ...

  2. [源码解析] 分布式任务队列 Celery 之启动 Consumer

    [源码解析] 分布式任务队列 Celery 之启动 Consumer 目录 [源码解析] 分布式任务队列 Celery 之启动 Consumer 0x00 摘要 0x01 综述 1.1 kombu.c ...

  3. Eclipse 中Tomcat 启动 与直接启动Tomcat的区别

    这段时间不用Java 了突然发现在用的时候出问题了. 首先现在Eclipse和Tomcat,解压后 如图1所示: 图1: 进入里面的bin文件目录后发现有 如图2所示包含了startup.bat,st ...

  4. init进程 && 解析Android启动脚本init.rc && 修改它使不启动android && init.rc中启动一个sh文件

    Android启动后,系统执行的第一个进程是一个名称为init 的可执行程序.提供了以下的功能:设备管理.解析启动脚本.执行基本的功能.启动各种服务.代码的路径:system/core/init,编译 ...

  5. Centos7启动流程及systemd中Nginx启动配置

    Centos7启动流程: 1.post(Power-On-Self-Test) 加电自检 主要实现的功能是检测各个外围硬件设备是否存在而且能够正常运行起来,实现这一自检功能的是固化在主板上的ROM(主 ...

  6. 使用Supervisor管理Celery进程。

    讲过一篇celery的,但是celery启动后并不是daemon的,在生产环境中这肯定是不可以的,那怎么办呢? 这就需要使用supervisor进行进程管理了,下面详细介绍. 一. superviso ...

  7. celery和supervisor配合使用,实现supervisor管理celery进程

    在这里我选择redis作为celery异步任务的中间人,系统选择CentOS6.5 64位.redis.celery和supervisor的安装参见官方文档. 安装完毕后: 1, 创建celery的实 ...

  8. 使用 supervisor 管理 Celery 服务

    使用 supervisor 管理 Celery 服务 Celery 后台运行 如果我们想让celery worker运行在后台而不是终端上,在后台以守护进程的方式运行,我们可以使用supervisor ...

  9. 异步任务队列Celery在Django中的使用

    前段时间在Django Web平台开发中,碰到一些请求执行的任务时间较长(几分钟),为了加快用户的响应时间,因此决定采用异步任务的方式在后台执行这些任务.在同事的指引下接触了Celery这个异步任务队 ...

随机推荐

  1. Jquery 文字模拟输入效果

    https://github.com/mattboldt/typed.js/ 挺酷炫的

  2. Java中的class类的cast方法和asSubclass方法

    一般来说cast是转型的意思,但是学java的时间也不短了,class类居然还有cast这个方法,这里来学习一下这个cast有何用. 第一次看到这个cast是在Spring的源码中, spring-f ...

  3. 压力测试工具ab,wrk,locust简介

    ab 无疑是目前最常见的压力测试工具.其典型用法如下: shell> ab -k -c 100 -t 10 http://domain/path 其中,参数「c」表示的是并发, 参数「t」表示的 ...

  4. 对H.264帧类型判断方法

    背景描述 我们经常在网络直播推流或者客户端拉流的时候,需要对获取到的H.264视频帧进行判断后处理,我们经常获取到各种不同的视频数据0x67 0x68 0x65 0x61,0x27 0x28 0x25 ...

  5. css3-calc用法

    css3--calc()使用 css3新增的一个功能,可以计算元素的长度 例如说:一个百分百布局中,分左右两侧,中间需要一个分隔空间,使用padding或者margin则会超出100%,这时候使用ca ...

  6. Redis 单例、主从模式、sentinel 以及集群的配置方式及优缺点对比(转)

    摘要: redis作为一种NoSql数据库,其提供了一种高效的缓存方案,本文则主要对其单例,主从模式,sentinel以及集群的配置方式进行说明,对比其优缺点,阐述redis作为一种缓存框架的高可用性 ...

  7. xcode7和ios9下UIWebView不能加载网页的解决方法

    错误描述: App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecu ...

  8. JavaWeb浏览器传值乱码

    在Java服务接口调用中,可能会出现乱码,如下图所示: 这是由编码不一致而致的乱码,可转,如下: name = new String(name.getBytes("ISO-8859-1&qu ...

  9. redis 使用 get 命令读取 bitmap 类型的数据

    在签到统计场景中,可以使用 bitmap 数据类型高效的存储签到数据,但 getbit 命令只能获取某一位值,就无法最优的满足部分业务场景了. 比如我们按年去存储一个用户的签到情况,365 天,只需要 ...

  10. bzoj1556 (DP)

    bzoj 1556 点这里打开题目 题目是求 a^2 求和: 原问题可以转化为:两个人在玩这个东西,问这两个人弄出来的序列相同的有多少种情况,操作方式不同即为一种不同的情况. 就这个问题,参考大佬的D ...