重新加载 systemd 配置推荐使用pip的方式安装
pip install supervisor
第二步:添加supervisord.conf配置文件
[unix_http_server]
file=/tmp/supervisor.sock ; UNIX socket 文件,supervisorctl 会使用
;chmod=0700 ; socket 文件的 mode,默认是 0700
;chown=nobody:nogroup ; socket 文件的 owner,格式: uid:gid
; [inet_http_server] ; HTTP 服务器,提供 web 管理界面
; port=0.0.0.0:8080 ; Web 管理后台运行的 IP 和端口,如果开放到公网,需要注意安全性
; username=root ; 登录管理后台的用户名
; password=1123 ; 登录管理后台的密码
[supervisord]
logfile=/tmp/supervisord.log ; 日志文件,默认是 $CWD/supervisord.log
logfile_maxbytes=50MB ; 日志文件大小,超出会 rotate,默认 50MB
logfile_backups=10 ; 日志文件保留备份数量默认 10
loglevel=info ; 日志级别,默认 info,其它: debug,warn,trace
pidfile=/tmp/supervisord.pid ; pid 文件
nodaemon=false ; 是否在前台启动,默认是 false,即以 daemon 的方式启动
minfds=1024 ; 可以打开的文件描述符的最小值,默认 1024
minprocs=200 ; 可以打开的进程数的最小值,默认 200
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; 通过 UNIX socket 连接 supervisord,路径与 unix_http_server 部分的 file 一致
; serverurl=http://127.0.0.1:8080 ; 通过 HTTP 的方式连接 supervisord
; 包含其他的配置文件【可以是 *.conf 或 *.ini】
[include]
files = /etc/supervisor/*.conf /etc/supervisor/common/*.conf
第三步:配置 supervisord.service文件
手动创建 supervisord.service
如果 supervisord.service 不存在,你可以手动创建:
vim /etc/systemd/system/supervisord.service
# supervisord service for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/local/anaconda3/bin/supervisord
ExecStop=/usr/local/anaconda3/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/anaconda3/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
重新加载 systemd 配置
sudo systemctl daemon-reload
最后tab补全支持【】
yum install bash-completion
启用 Bash 补全
确保 Bash 补全已启用。在 ~/.bashrc 或 /etc/bash.bashrc 中添加以下内容:
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
然后重新加载 Bash 配置:
source ~/.bashrc
最后执行 systemctl restart supervisord.service 补全试试