CentOS 中安装 supervisor 4.2.2
因服务器已安装Python 3.8.0,所以直接安装Supervisor 4.2.2
1. 安装
pip install supervisor or pip3 install supervisor
2. 检测是否安装成功
supervisord -v
3. 生成配置文件
mkdir -p /etc/supervisor/conf.d
echo_supervisord_conf > /etc/supervisor/supervisord.conf
4. 编辑配置文件
vim /etc/supervisor/supervisord.conf
[inet_http_server]
port=*:9001
username=admin
password=123456
[include]
files = /etc/supervisor/conf.d/*.conf
5. 单独配置要守护的程序
在 /etc/supervisor/conf.d/ 下创建配置文件 datacheck.conf
[program:datacheck]
command=dotnet datacheck.dll
directory=/var/www/www.datacheck.com/
stderr_logfile=/var/log/datacheck.error.log
stdout_logfile=/var/log/datacheck.stdout.log
environment=ASPNETCORE_ENVIRONMENT=datacheck
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=3
6. 启动
supervisord -c /etc/supervisor/supervisord.conf
7. 设置开机启动
7.1 vim /usr/lib/systemd/system/supervisord.service
[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service nss-user-lookup.target
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ;开机启动时执行
ExecStop=/usr/bin/supervisord stop
ExecReload=/usr/bin/supervisord reload
killMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
7.2 启动服务
systemctl enable supervisord
7.3 验证是否为开机启动
systemctl is-enabled supervisord
8. 其他命令
# 重新加载配置 supervisorctl reload
# 更新任务 supervisorctl update
# 开启全部任务 supervisorctl start all
# 停止全部任务 supervisorctl stop all
# 重启全部任务 supervisorctl restart all
# 查看任务状态 supervisorctl status all
浙公网安备 33010602011771号