安装supervisor pip方式 1 2 3 4 wget https://bootstrap.pypa.io/get-pip.py python get-pip.py rm -rf get-pip.py pip install supervisor
apt方式 1 apt-get install supervisor
配置supervisor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 echo_supervisord_conf > /etc/supervisor/supervisord.conf(配置文件位置) echo "supervisord" >> /etc/rc.localcat >>/etc/supervisord.conf<<'EOF' [program:relaysrv] command =relaysrv -keys /etc/relaysrv -pools="" autostart=true autorestart=true startsecs=10 stdout_logfile=/var/log /relaysrv.log stdout_logfile_maxbytes=1MB stdout_logfile_backups=10 stdout_capture_maxbytes=1MB redirect_stderr=true user = root EOF
配置Supervisor开机启动 配置systemctl 进入/lib/systemd/system目录,并创建supervisor.service文件,该文件内容如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 root@VC:/lib/systemd/system supervisord: *查到的地址*/supervisord root@VC:/lib/systemd/system supervisorctl: *查到的地址*/supervisorctl root@VC:/lib/systemd/system [Unit] Description=supervisor After=network.target [Service] Type=forking ExecStart=*查到的地址*/supervisord -c *配置文件位置*/supervisord.conf ExecStop=*查到的地址*/supervisorctl $OPTIONS shutdown ExecReload=*查到的地址*/supervisorctl $OPTIONS reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target
设置开机启动 1 2 3 root@VC:/lib/systemd/system Created symlink from /etc/systemd/system/multi-user.target.wants/supervisor.service to /lib/systemd/system/supervisor.service. root@VC:/lib/systemd/system
修改文件权限为766 1 root@VC:/lib/systemd/system
supervisorctl命令行下的命令: 1 2 3 4 5 6 7 8 9 10 11 supervisorctl status supervisorctl celery status supervisorctl stop xxx supervisorctl start xxx supervisorctl restart xxx supervisorctl stop groupworker supervisorctl stop all supervisorctl reload supervisorctl update supervisorctl shutdown