supervisor 配置

報錯總結如下

更新apt

sudo apt update && sudo apt upgrade

pip3 install supervisor

<!--生成配置文件-->
echo_supervisord_conf > /etc/supervisord.conf

常用命令

supervisorctl   status              查看狀態(tài)
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、首先執(zhí)行命令:systemctl is-enabled supervisord ,結果如下圖:提示尚未為supervisor配置開機啟動

2、在shell里執(zhí)行 vim /lib/systemd/system/supervisord.service 編輯開機啟動時執(zhí)行的腳本如下

[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

原因,默認配置的目錄不存在, 手動創(chuàng)建一個就好了mkdir /run/supervisor

?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容