supervisor使用报错解决
常用命令
supervisorctl status 查看状态
supervisorctl reload 重新载入配置文件
supervisorctl start all/ftp 启动所有/指定的程序进程
supervisorctl stop all/frp 关闭所有/指定的程序进程
一.简化后的supervisord.conf配置文件内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [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=50 MB ; (max main logfile bytes b4 rotation;default 50 MB ) 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 编辑开机启动时执行的脚本如下
1 2 3 4 5 6 7 8 9 10 11 12 | [ 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
1 2 3 4 5 6 7 | <!--启动--> 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’
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
或者
1 | supervisord -c /etc/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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器