1、错误unix:///tmp/supervisor.sock no such file
[root@ ~]# supervisorctl
unix:///tmp/supervisor.sock no such file
supervisor> version
unix:///tmp/supervisor.sock no such file
---------
[root@ ~]# whereis supervisord
supervisord: /etc/supervisord.conf /root/anaconda2/bin/supervisord
cd进/tmp/目录看下,没有supervisor.sock文件。supervisor默认配置会把socket文件和pid守护进程生成在/tmp/目录下,/tmp/目录是缓存目录,Linux会根据不同情况自动删除其下面的文件。
vim /etc/supervisord.conf
修改如下标示的几行即可
[unix_http_server]
;file=/tmp/supervisor.sock ; (the path to the socket file)
file=/var/run/supervisor.sock ; 修改为 /var/run 目录,避免被系统删除
;chmod=0700 ; socket file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
...
[supervisord]
;logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile=/var/log/supervisor/supervisord.log ; 修改为 /var/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=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
pidfile=/var/run/supervisord.pid ; 修改为 /var/run 目录,避免被系统删除
...
[supervisorctl]
; 必须和'unix_http_server'里面的设定匹配
;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
serverurl=unix:///var/run/supervisor.sock ; 修改为 /var/run 目录,避免被系统删除
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
...
检查/var/run、/var/log存在
杀掉supervisord
//启动supervisord
supervisord -c /etc/supervisord.conf
//加载更新过的配置文件
supervisorctl reload
supervisorctl restart all
至此就可以了,socket文件supervisor.sock和守护进程supervisord.pid两个文件放在/var/run/下面,log文件supervisord.log放在/var/log/下面。
2、错误error: <class ‘socket.error’>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
- 先确保supervisord.conf中有[supervisord],[supervisorctl]有这两个基本模块,还有[program:XXX]自己程序的配置(可以在supervisord.conf也可以在/etc/supervisor/*.ini中)
- 最关键的两个命令:chmod +x /usr/bin/supervisord
chmod +x /usr/bin/supervisorctl
chmod +x /etc/supervisord.conf主要是把把相关文件都授权了 - 把supervisord杀掉后再次启动supervisord
supervisord -c /etc/supervisord.conf