报错总结如下
更新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
网友评论