Supervisor
大约 1 分钟约 326 字
Supervisor
安装
yum install -y epel-release
yum install supervisor
提示
- 默认配置文件:/etc/supervisord.conf
- 进程管理配置文件放到:/etc/supervisord.d/目录下即可
配置文件中 /etc/supervisord.conf 注意include的文件夹以及后缀
[include]
files = supervisord.d/*.ini
增加配置文件示例
cd /etc/supervisord.d
vi testnetcore.ini
# 内容
[program:testnetcore]
command=dotnet testnetcore.dll --urls http://*:8090
directory=/home/testnetcore/publish/
autorestart=true
startsecs=3
startretries=3
stdout_logfile=/home/testnetcore/publish/testnetcore.out.log
stderr_logfile=/home/testnetcore/publish/testnetcore.err.log
stdout_logfile_maxbytes=2MB
stderr_logfile_maxbytes=2MB
user=root
priority=999
numprocs=1
process_name=%(program_name)s_%(process_num)02d
启动
supervisord -c /etc/supervisord.conf
开机启动
systemctl enable supervisor.service
启动supervisor服务
supervisord -c /etc/supervisord.conf
常用命令
sudo service supervisor stop #停止supervisor服务
sudo service supervisor start #启动supervisor服务
supervisorctl shutdown #关闭所有任务
supervisorctl stop|start program_name #启动或停止服务
supervisorctl status #查看所有任务状态
# 如果新增了配置文件 可以在命令行使用 update更新子任务
sudo supervisorctl update # 默认更新全部 后面加 任务文件名 启动特定任务
sudo supervisorctl reread 重载配置(新增配置文件)
配置supervisord开机启动
vi /usr/lib/systemd/system/supervisord.service
# 内容==============
[Unit]
Description=Supervisor daemon
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
# =======================
# 设置开机启动
systemctl enable supervisord
# 验证开机启动
systemctl is-enabled supervisord