將netcore打包好的程式,以守護程序方式部署到CentOS系統中

低调码农哥!發表於2024-05-14

進入 守護程序目錄:

 cd etc/systemd/system

建立守護進行服務:

vi my-auth.service

 將如下程式碼更改為對應的服務,儲存後退回

[Unit]

Description=Auth .NET Web API App running on CentOS


[Service]

WorkingDirectory=/home/auth

ExecStart=/usr/bin/dotnet /home/auth/Howdy.Net6API.AuthenticationCenter.dll

Restart=always

# Restart service after 10 seconds if the dotnet service crashes:

RestartSec=10

SyslogIdentifier=my-auth

User=root

Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]

WantedBy=multi-user.target

檢視服務狀態

systemctl status  my-auth.service 

啟動服務

 systemctl start my-auth.service

停止服務

 systemctl stop my-auth.service

重啟服務

 systemctl  restart my-auth.service

設定開機自啟動

 systemctl enable  my-auth 

相關文章