supervisor篇---使用报错解决

更新apt

sudo apt update && sudo apt upgrade

pip3 install supervisor

<!--生成配置文件-->
echo_supervisord_conf > /etc/supervisord.conf

常用命令

supervisorctl   status              查看状态
supervisorctl   reload              重新载入配置文件
supervisorctl   start all/ftp     启动所有/指定的程序进程
supervisorctl   stop all/frp      关闭所有/指定的程序进程 

简化后的supervisord.conf配置文件内容:

[unix_http_server]
file=/run/supervisor/supervisor.sock   ; (the path to the socket file)

[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket

[include]
files = supervisor.d/*.conf

注意 所有需要用supervisor管理的服务放在/etc/supervisor.d/目录下;

supervisor开机自启

1、首先执行命令:systemctl is-enabled supervisord ,结果如下图:提示尚未为supervisor配置开机启动

2、在shell里执行 vim /lib/systemd/system/supervisord.service 编辑开机启动时执行的脚本如下

[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
RuntimeDirectory=supervisor
RuntimeDirectoryMode=755

[Install]
WantedBy=multi-user.target

注意:ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf 一定要这样写,supervisor安装完默认会在/etc/supervisord.conf 产生

启动程序

systemctl enable supervisord

验证一下是否为开机启动:

systemctl is-enabled supervisord

二. “supervisor.sock no such file”的解决方法

1:去/run/supervisor中touch一个supervisor.sock文件 并chmod 777 supervisor.sock
2:kill 掉所有之前的supervisor进程
3:启动supervisor

<!--启动-->
systemctl start supervisor

supervisord -c /etc/supervisord.conf

<!--关闭-->
systemctl stop supervisor

重新启动supervisor

三:Error: Cannot open an HTTP server: socket.error reported errno.ENOENT (2)

supervisord -c /etc/supervisord.conf 启动时报错

Error: Cannot open an HTTP server: socket.error reported errno.ENOENT (2)
For help, use /usr/bin/supervisord -h

原因,默认配置的目录不存在, 手动创建一个就好了**mkdir /run/supervisor**

四: Unlinking stale socket /tmp/supervisor、unix:/run/supervisor/supervisor.sock no such file

supervisor出现Unlinking stale socket /tmp/supervisor、unix:/run/supervisor/supervisor.sock no such file。遇到以上类似的问题,可以通过以下步骤得到解决。

1、修改配置文件

vim supervisord.conf
这里把所有的/tmp路径改掉,

/tmp/supervisor.sock 改成/var/run/supervisor.sock,
/tmp/supervisord.log 改成/var/log/supervisor.log,
/tmp/supervisord.pid 改成 /var/run/supervisor.pid 要不容易被linux自动清掉。

样例如下:

[unix_http_server]
file=/run/supervisor/supervisor.sock   ; the path to the socket file

[supervisord]
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log

pidfile=/run/supervisor/supervisord.pid ; supervisord pidfile; default supervisord.pid

[supervisorctl]
serverurl=unix:///run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket

2、修改权限

sudo chmod 777 -R /run
sudo chmod 777 -R /var

如果没改,启动可能会报错 IOError: [Errno 13] Permission denied: ‘/var/log/supervisord.log’

3、创建supervisor.sock

sudo touch /run/supervisor/supervisor.sock
sudo chmod 777 /run/supervisor/supervisor.sock
sudo chmod 777 -R /run

4、添加supervisor.sock链接

unlink /run/supervisor/supervisor.sock

5、启动supervisord

注意stop之前的实例或杀死进程。

supervisord
或者
supervisord -c /home/Nox/conf/nox/supervisord.conf

五:Exited too quickly (process log may have details)

使用supervisor监控程序查看状态总是报Exited too quickly (process log may have details),退出太快?这报错真是挺无奈的,网上所有办法都试了一遍,没什么用。

后来经过本人孜孜不倦的调试,反复琢磨,发现了一个很简单但是巨特么坑的地方。
报这个错的原因很简单,用supervisor监控程序,但是使用的是自己的方法启动程序,那当然不会监控成功,正确的做法是用supervisor重启。

supervisorctl restart 监控ID

在这里插入图片描述

六:unix:///run/supervisor/supervisor.sock refused connection

如果此时按照网上的方法手动新建一个supervisor.sock,就会出现refused connection的错误,然后网上的教程就说是软连接问题,需要解除一下,但是一解除这个文件就会被删除。所以那个教程还挺自相矛盾。

在这里插入图片描述
此时正确的做法是,应该重新指定配置文件,这样就能正确的生成一个sock文件

supervisord -c /etc/supervisord.conf

在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心惠天意

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值