Supervisor 部署


一、 下载

wget https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.3.tar.gz

二 、 解压

tar zxvf supervisor-3.1.3.tar.gz

三、 安装

cd supervisor-3.1.3
python setup.py install

四、 创建 目录、配置文件、启动文件

mkdir -p /etc/supervisord.d/
touch /etc/supervisord.conf
touch /usr/lib/systemd/system/supervisord.service

五、 修改配置文件

cat >> /etc/supervisord.conf << EOF

[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=1024000                  ; 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:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

[include]
files = /etc/supervisord.d/*.ini

EOF

六、 配置service文件

cat >> /usr/lib/systemd/system/supervisord.service << EOF

[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target

[Service]
LimitNPROC=65535
LimitNOFILE=65535
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
User=root

[Install]
WantedBy=multi-user.target

EOF

七、 启动

systemctl daemon-reload
systemctl start supervisord.service
systemctl enable supervisord.service