一、基础信息
安装环境:
CentOS Linux release 7.4.1708 (Core)
Supervisor安装包:
地址:https://pypi.org/project/supervisor/3.3.4/
二、安装
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -;pip install meld3
#安装python-setuptools
rpm -qa | grep python-setuptools||yum -y install python-setuptools
#下载supervisor-3.3.4安装包
wget https://files.pythonhosted.org/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz
#解压
tar -zxvf supervisor-3.3.4.tar.gz
cd supervisor-3.3.4/
#执行安装
python setup.py install
#确认版本
supervisord -v
3.3.4
三、配置
#配置模板:./supervisor/skel/sample.conf
IP=$(ifconfig $(route -n | grep ^0.0.0.|awk '{print$NF}') | grep "inet "|awk '{print$2}')
cat << EOF > /etc/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; the path to the socket file
[supervisord]
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
loglevel=info ; log level; default info; others: debug,warn,trace
pidfile=/var/run/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false ; start in foreground if true; default false
minfds=65536 ; min. avail startup file descriptors; default 1024
minprocs=200 ; min. avail process descriptors;default 200
childlogdir=/data/supervisor ; 'AUTO' child log dir, default $TEMP
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /etc/supervisord.d/*.ini
EOF
#配置目录
mkdir -p /data/supervisor
mkdir -p /etc/supervisord.d
四、Systemd配置
cat <<EOF> /lib/systemd/system/supervisord.service
[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service nss-user-lookup.target
[Service]
LimitNPROC=65535
LimitNOFILE=65535
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start supervisord
# 开机启动
systemctl enable supervisord