supervisor使用报错解决

常用命令

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

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

[unix_http_server]
file=/var/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:///var/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=/var/run/supervisor/supervisor.sock ; the path to the socket file

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

pidfile=var/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 /var/run/supervisor/supervisor.sock
sudo chmod 777 /var/run/supervisor/supervisor.sock
sudo chmod 777 -R /var/run

4、添加supervisor.sock链接

unlink /var/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重启。

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

此时正确的做法是,应该重新指定配置文件,这样就能正确的生成一个sock文件

supervisord -c /etc/supervisord.conf

 

 

 

 

 

 

 

 

 

 
posted @ 2024-10-17 11:42  好名字可以让你的朋友更容易记住你  阅读(24)  评论(0编辑  收藏  举报