Centos8安装Supervisor
1.Supervisor安装
准备工作:
dnf install python3.8 -y
正式安装:
wget https://pypi.python.org/packages/source/s/supervisor/supervisor-4.2.0.tar.gz tar zxvf supervisor-4.2.0.tar.gz cd supervisor-4.2.0 /usr/bin/python3.8 setup.py install mkdir /usr/supervisor echo_supervisord_conf > /usr/supervisor/supervisord.conf mkdir /usr/supervisor/supervisord.d/
1.1 点击下载此文件:supervisord.conf ,并使用该文件替换 /usr/supervisor/supervisord.conf 原文件
1.2 /usr/supervisor/supervisord.d/目录下的conf文件模板
my_webapi.conf
[program:my_webapi]
directory =/var/www/webApi
command =dotnet My.WebApi.dll --urls "http://*:9991"
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /var/www/logs/my_webapi_supervisor.log
2.添加开机自启动脚本
2.1 cd /lib/systemd/system/
2.2 vim supervisord.service
[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service nss-user-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/bin/supervisord -c /usr/supervisor/supervisord.conf
ExecStop=/usr/local/bin/supervisord shutdown
ExecReload=/usr/local/bin/supervisord reload
killMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
2.3 systemctl enable supervisord (启用开机启动)
3.启动
systemctl start supervisord
4.supervisorctl 命令介绍
update 更新新的配置到supervisord(不会重启原来已运行的程序)
reload,载入所有配置文件,并按新的配置启动、管理所有进程(会重启原来已运行的程序)
start xxx: 启动某个进程
restart xxx: 重启某个进程
stop xxx: 停止某一个进程(xxx),xxx为[program:theprogramname]里配置的值
stop groupworker: 重启所有属于名为groupworker这个分组的进程(start,restart同理)
stop all,停止全部进程,注:start、restart、stop都不会载入最新的配置文
reread,当一个服务由自动启动修改为手动启动时执行一下就ok
5.引用地址
其他问题可参考https://www.cnblogs.com/toutou/p/supervisor.html(第二种方式安装)