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

相关文章

线上Java OOM问题定位与解决方案超详细解析

《线上JavaOOM问题定位与解决方案超详细解析》OOM是JVM抛出的错误,表示内存分配失败,:本文主要介绍线上JavaOOM问题定位与解决方案的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录一、OOM问题核心认知1.1 OOM定义与技术定位1.2 OOM常见类型及技术特征二、OOM问题定位工具

Vue3绑定props默认值问题

《Vue3绑定props默认值问题》使用Vue3的defineProps配合TypeScript的interface定义props类型,并通过withDefaults设置默认值,使组件能安全访问传入的... 目录前言步骤步骤1:使用 defineProps 定义 Props步骤2:设置默认值总结前言使用T

Web服务器-Nginx-高并发问题

《Web服务器-Nginx-高并发问题》Nginx通过事件驱动、I/O多路复用和异步非阻塞技术高效处理高并发,结合动静分离和限流策略,提升性能与稳定性... 目录前言一、架构1. 原生多进程架构2. 事件驱动模型3. IO多路复用4. 异步非阻塞 I/O5. Nginx高并发配置实战二、动静分离1. 职责2

解决升级JDK报错:module java.base does not“opens java.lang.reflect“to unnamed module问题

《解决升级JDK报错:modulejava.basedoesnot“opensjava.lang.reflect“tounnamedmodule问题》SpringBoot启动错误源于Jav... 目录问题描述原因分析解决方案总结问题描述启动sprintboot时报以下错误原因分析编程异js常是由Ja

MySQL 表空却 ibd 文件过大的问题及解决方法

《MySQL表空却ibd文件过大的问题及解决方法》本文给大家介绍MySQL表空却ibd文件过大的问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考... 目录一、问题背景:表空却 “吃满” 磁盘的怪事二、问题复现:一步步编程还原异常场景1. 准备测试源表与数据

SpringBoot通过main方法启动web项目实践

《SpringBoot通过main方法启动web项目实践》SpringBoot通过SpringApplication.run()启动Web项目,自动推断应用类型,加载初始化器与监听器,配置Spring... 目录1. 启动入口:SpringApplication.run()2. SpringApplicat

解决Nginx启动报错Job for nginx.service failed because the control process exited with error code问题

《解决Nginx启动报错Jobfornginx.servicefailedbecausethecontrolprocessexitedwitherrorcode问题》Nginx启... 目录一、报错如下二、解决原因三、解决方式总结一、报错如下Job for nginx.service failed bec

SysMain服务可以关吗? 解决SysMain服务导致的高CPU使用率问题

《SysMain服务可以关吗?解决SysMain服务导致的高CPU使用率问题》SysMain服务是超级预读取,该服务会记录您打开应用程序的模式,并预先将它们加载到内存中以节省时间,但它可能占用大量... 在使用电脑的过程中,CPU使用率居高不下是许多用户都遇到过的问题,其中名为SysMain的服务往往是罪魁

MySQ中出现幻读问题的解决过程

《MySQ中出现幻读问题的解决过程》文章解析MySQLInnoDB通过MVCC与间隙锁机制在可重复读隔离级别下解决幻读,确保事务一致性,同时指出性能影响及乐观锁等替代方案,帮助开发者优化数据库应用... 目录一、幻读的准确定义与核心特征幻读 vs 不可重复读二、mysql隔离级别深度解析各隔离级别的实现差异

C++ vector越界问题的完整解决方案

《C++vector越界问题的完整解决方案》在C++开发中,std::vector作为最常用的动态数组容器,其便捷性与性能优势使其成为处理可变长度数据的首选,然而,数组越界访问始终是威胁程序稳定性的... 目录引言一、vector越界的底层原理与危害1.1 越界访问的本质原因1.2 越界访问的实际危害二、基