Supervisor 守护 dotnet 进程
使用 Supervisor 守护 .NET Web 应用(示例 SmartDW.WebApi),在 /etc/supervisor/conf.d/ 下新建配置文件,写入以下内容:
[program:smartapi]
command=/usr/local/dotnet /web/SmartDW.WebApi.dll --urls http://*:8001
directory=/mnt/001SH1Group/publish/api/smartwebapi
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=1
stderr_logfile=/var/log/supervisor/smartapi.err.log
stdout_logfile=/var/log/supervisor/smartapi.out.log配置项说明
[program:smartapi]:声明要创建的进程,smartapi是进程名称command:用什么程序执行目标应用;--urls http://*:8001指定监听端口号directory:当前需要守护的程序所在目录environment:配置当前应用需要的环境变量,如ASPNETCORE_ENVIRONMENT=Productionstopsignal=INT:停止时发送的信号,便于优雅退出autostart/autorestart:开机自启与崩溃后自动重启
配置多个环境变量
需要多个环境变量时,用逗号分隔:
environment=HOME="/home/username",USER="username",LD_PRELOAD="/home/username/usr/lib/libgdal.so.1"
评论区