supervisor 启动 celery 及启动中的问题

2024-05-13 00:08

本文主要是介绍supervisor 启动 celery 及启动中的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、前言

本教程重点在于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=nobody
numprocs=1
stdout_logfile=/var/log/celery/worker.log ;celery输出日志文件
stderr_logfile=/var/log/celery/workererr.log ;celery错误输出文件
autostart=true
autorestart=true
startsecs=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





这篇关于supervisor 启动 celery 及启动中的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/984126

相关文章

Spring的RedisTemplate的json反序列泛型丢失问题解决

《Spring的RedisTemplate的json反序列泛型丢失问题解决》本文主要介绍了SpringRedisTemplate中使用JSON序列化时泛型信息丢失的问题及其提出三种解决方案,可以根据性... 目录背景解决方案方案一方案二方案三总结背景在使用RedisTemplate操作redis时我们针对

Kotlin Map映射转换问题小结

《KotlinMap映射转换问题小结》文章介绍了Kotlin集合转换的多种方法,包括map(一对一转换)、mapIndexed(带索引)、mapNotNull(过滤null)、mapKeys/map... 目录Kotlin 集合转换:map、mapIndexed、mapNotNull、mapKeys、map

nginx中端口无权限的问题解决

《nginx中端口无权限的问题解决》当Nginx日志报错bind()to80failed(13:Permissiondenied)时,这通常是由于权限不足导致Nginx无法绑定到80端口,下面就来... 目录一、问题原因分析二、解决方案1. 以 root 权限运行 Nginx(不推荐)2. 为 Nginx

解决1093 - You can‘t specify target table报错问题及原因分析

《解决1093-Youcan‘tspecifytargettable报错问题及原因分析》MySQL1093错误因UPDATE/DELETE语句的FROM子句直接引用目标表或嵌套子查询导致,... 目录报js错原因分析具体原因解决办法方法一:使用临时表方法二:使用JOIN方法三:使用EXISTS示例总结报错原

Windows环境下解决Matplotlib中文字体显示问题的详细教程

《Windows环境下解决Matplotlib中文字体显示问题的详细教程》本文详细介绍了在Windows下解决Matplotlib中文显示问题的方法,包括安装字体、更新缓存、配置文件设置及编码調整,并... 目录引言问题分析解决方案详解1. 检查系统已安装字体2. 手动添加中文字体(以SimHei为例)步骤

SpringSecurity整合redission序列化问题小结(最新整理)

《SpringSecurity整合redission序列化问题小结(最新整理)》文章详解SpringSecurity整合Redisson时的序列化问题,指出需排除官方Jackson依赖,通过自定义反序... 目录1. 前言2. Redission配置2.1 RedissonProperties2.2 Red

nginx 负载均衡配置及如何解决重复登录问题

《nginx负载均衡配置及如何解决重复登录问题》文章详解Nginx源码安装与Docker部署,介绍四层/七层代理区别及负载均衡策略,通过ip_hash解决重复登录问题,对nginx负载均衡配置及如何... 目录一:源码安装:1.配置编译参数2.编译3.编译安装 二,四层代理和七层代理区别1.二者混合使用举例

怎样通过分析GC日志来定位Java进程的内存问题

《怎样通过分析GC日志来定位Java进程的内存问题》:本文主要介绍怎样通过分析GC日志来定位Java进程的内存问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、GC 日志基础配置1. 启用详细 GC 日志2. 不同收集器的日志格式二、关键指标与分析维度1.

Java 线程安全与 volatile与单例模式问题及解决方案

《Java线程安全与volatile与单例模式问题及解决方案》文章主要讲解线程安全问题的五个成因(调度随机、变量修改、非原子操作、内存可见性、指令重排序)及解决方案,强调使用volatile关键字... 目录什么是线程安全线程安全问题的产生与解决方案线程的调度是随机的多个线程对同一个变量进行修改线程的修改操

Redis出现中文乱码的问题及解决

《Redis出现中文乱码的问题及解决》:本文主要介绍Redis出现中文乱码的问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1. 问题的产生2China编程. 问题的解决redihttp://www.chinasem.cns数据进制问题的解决中文乱码问题解决总结