5、supervisor安装使用

官方文档

http://supervisord.org/installing.html#installing-to-a-system-with-internet-access

1、安装

yum install supervisor 

开机启动

systemctl enable supervisord.service

2、配置文件

mkdir /etc/supervisor
echo_supervisord_conf > /etc/supervisor/supervisord.conf

修改新建的supervisord.conf配置信息

最后两行

[include]
files = /etc/supervisor/conf.d/*.ini

然后修改【inet-http_srever】节点

 这里貌似有个坑,这个端口最好别用9001,不知道什么情况会触发端口占用

/etc/supervisor/目录下创建名字为conf.d文件夹,在conf.d目录中建GameApi.ini文件,内容如下

[program:GameApi]
command=dotnet GameApi.dll ; 运行程序的命令
directory=/app/ ; 命令执行的目录
autorestart=true ; 程序意外退出是否自动重启
stderr_logfile=/var/log/GameApi.err.log ; 错误日志文件
stdout_logfile=/var/log/GameApi.out.log ; 输出日志文件
environment=ASPNETCORE_ENVIRONMENT=Development ; 进程环境变量
user=root ; 进程执行的用户身份
stopsignal=INT

设置一下开机启动的配置

vim /usr/lib/systemd/system/supervisord.service

3、启动 supervisor

supervisord -c /etc/supervisor/supervisord.conf

查看我们的程序是否启动成功

ps -ef | grep GameApi.dll

 这个工具只能单点使用,比如你自己弄个游戏key服务,或者是自己的开发调试,如果集群的话,不太友好,所以知道一下就可以了

附录

[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
RuntimeDirectory=supervisor
RuntimeDirectoryMode=755

[Install]
WantedBy=multi-user.target

原文地址:https://www.cnblogs.com/ares-core/p/12960644.html