写在前面
Supervisor 是一个用 Python 开发的进程管理工具,常用于服务器环境下的进程监控和管理。在日常使用过程中,我们经常会遇到各种配置、运行和日志相关的问题。
本文将汇总记录我在实际工作中使用 Supervisor 时遇到的各种典型问题及其解决方案。
常见问题
1.报错 unix:///var/run/supervisor.sock no such file
解决方案
方案1:
1.1.先停止supervisor
systemctl sotp supervisor.service
1.2.查看是否有supervisord进程没有结束,并杀死
ps -ef | grep supervisor | grep -v grep | cut -c 9-15 | xargs kill -9
方案2:
2.1使用以下命令,重新加载配置文件。整个服务会自动启动
supervisord -c /etc/supervisor/supervisord.conf #使用-n -c的话可同时在终端看到运行日志及报错(如果有报错的话)
#或
/usr/bin/python2 /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
2.报错 Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
解决方案
因为9001获取其他你设置的端口被占用了,你可以先
lsof -i:9002
kill:pid
再重新执行该命令就可以了;
3.报错 [Errno 13] Permission denied: ‘/tmp/supervisord.log’
解决方案
加sudo执行,主要是访问路径需要root权限,可考虑将路径修改为本地home路径下
4.报错 [line 57]: ‘json module not found, using jsonujson module not found, using jsonujson module not found, using json\n’
解决方案
这个问题不是json模块找不到,是配置文件格式不对,仔细检查或重写配置文件就能搞定!!!
5.报错 Error: .ini file does not include supervisorctl section
解决方案
1.先确保supervisord.conf中有[supervisord],[supervisorctl]有这两个基本模块,还有[program:XXX]自己程序的配置(可以在supervisord.conf也可以在/etc/supervisor/*.ini中)
2.最关键的两个命令:
chmod +x /usr/bin/supervisord
chmod +x /usr/bin/supervisorctl
chmod +x /etc/supervisord.conf主要是把把相关文件都授权了
3.把supervisord杀掉后再次启动supervisord
The end.