supervisor 启动 celery 及启动中的问题
来源:互联网 发布:不同域名的区别 编辑:程序博客网 时间:2024/06/08 02:41
一、前言
本教程重点在于supervisor的配置过程,celery的安装配置请参考其他教程
二、安装supervisor
1.安装命令pip install supervisor # supervisor目前只支持python2,但是作为容器来说,并不影响监控程序是python3的程序
2.执行 配置文件 生成命令
echo_supervisord_conf > /etc/supervisord.conf
3.创建配置文件需要的文件夹
mkdir /var/log/celery/mkdir /var/log/celery/mkdir /var/log/supervisor/mkdir /var/run/supervisor/4.更改权限
mkdir /var/log/celery/mkdir /var/log/celery/mkdir /var/log/supervisor/mkdir /var/run/supervisor/5.编辑配置文件 /etc/supervisord.conf 加入celery配置项(本配置中没使用beat)
; ==================================; celery worker supervisor example; ==================================[program:celery]; 如果使用的是虚拟环境(virtualenv等)要把celery命令路径写全command=/home/hiveme/env/cznews/bin/celery worker -A cznews --loglevel=INFO; Alternatively,;command=celery --app=your_app.celery:app worker --loglevel=INFO -n worker.%%h; Or run a script;command=celery.shdirectory=/home/hiveme/cznews/ ;项目所在目录user=nobodynumprocs=1stdout_logfile=/var/log/celery/worker.log ;celery输出日志文件stderr_logfile=/var/log/celery/workererr.log ;celery错误输出文件autostart=trueautorestart=truestartsecs=10; Need to wait for currently executing tasks to finish at shutdown.; Increase this if you have very long running tasks.stopwaitsecs = 600; Causes supervisor to send the termination signal (SIGTERM) to the whole process group.stopasgroup=true; Set Celery priority higher than default (999); so, if rabbitmq is supervised, it will start first.priority=1000; ================================; celery beat supervisor example; ================================;[program:celerybeat]; Set full path to celery program if using virtualenv;command=/home/hiveme/env/cznews/bin/celery beat --schedule /var/lib/celery/beat.db --loglevel=INFO;command=celery beat -A myapp --schedule /var/lib/celery/beat.db --loglevel=INFO ;the ordinary; remove the -A myapp argument if you aren't using an app instance;directory=/home/hiveme/cznews/;user=nobody;numprocs=1;stdout_logfile=/var/log/celery/beat.log;stderr_logfile=/var/log/celery/beaterr.log;autostart=true;autorestart=true;startsecs=10; Causes supervisor to send the termination signal (SIGTERM) to the whole process group.;stopasgroup=true; if rabbitmq is supervised, set its priority higher; so it starts first;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
阅读全文
1 0
- supervisor 启动 celery 及启动中的问题
- 服务器虚拟环境下supervisor启动django-celery
- storm中supervisor的启动exit问题
- storm中supervisor的启动exit问题
- 安装启动 Supervisor
- supervisor后台启动shadowsocks
- XAMPP启动中的一些问题及解决办法
- storm启动supervisor源码分析-supervisor.clj
- python celery 使用及后台运行(supervisor)
- OTP中supervisor启动过程
- OTP中supervisor启动过程
- twitter storm supervisor 启动错误
- 用supervisor启动express4项目
- Docker使用supervisor启动Mysql
- Docker使用supervisor启动MongoDB
- JStorm之Supervisor启动流程
- 用supervisor启动express4项目
- CentOS7配置Supervisor开机启动
- 【美图-选择题考点整理-第一篇】
- Mysql远程数据库同步
- 怎么仿站下载整站的文件
- 7个提示在JavaScript中处理未定义
- nodejs -- for循环里面套异步解决 -- 类似并发
- supervisor 启动 celery 及启动中的问题
- LeetCode随笔之排序算法
- DecimalFormat 快速将小数转化为保留任意小数位数的String
- 【2017广西邀请赛】hdu 6188 Duizi and Shunzi 贪心
- 我开通CSDN博客了,就是为了存储网上看到的资源
- OPTION 125
- access数据库和SQLite数据库速度的简单对比
- IOS UIScrollView滚动内容自适应
- activity的启动模式分析