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

相关文章

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

Spring Boot中JSON数值溢出问题从报错到优雅解决办法

《SpringBoot中JSON数值溢出问题从报错到优雅解决办法》:本文主要介绍SpringBoot中JSON数值溢出问题从报错到优雅的解决办法,通过修改字段类型为Long、添加全局异常处理和... 目录一、问题背景:为什么我的接口突然报错了?二、为什么会发生这个错误?1. Java 数据类型的“容量”限制

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

usb接口驱动异常问题常用解决方案

《usb接口驱动异常问题常用解决方案》当遇到USB接口驱动异常时,可以通过多种方法来解决,其中主要就包括重装USB控制器、禁用USB选择性暂停设置、更新或安装新的主板驱动等... usb接口驱动异常怎么办,USB接口驱动异常是常见问题,通常由驱动损坏、系统更新冲突、硬件故障或电源管理设置导致。以下是常用解决

Mysql如何解决死锁问题

《Mysql如何解决死锁问题》:本文主要介绍Mysql如何解决死锁问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录【一】mysql中锁分类和加锁情况【1】按锁的粒度分类全局锁表级锁行级锁【2】按锁的模式分类【二】加锁方式的影响因素【三】Mysql的死锁情况【1

SpringBoot内嵌Tomcat临时目录问题及解决

《SpringBoot内嵌Tomcat临时目录问题及解决》:本文主要介绍SpringBoot内嵌Tomcat临时目录问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录SprinjavascriptgBoot内嵌Tomcat临时目录问题1.背景2.方案3.代码中配置t

SpringBoot使用GZIP压缩反回数据问题

《SpringBoot使用GZIP压缩反回数据问题》:本文主要介绍SpringBoot使用GZIP压缩反回数据问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot使用GZIP压缩反回数据1、初识gzip2、gzip是什么,可以干什么?3、Spr