centos netcore開機啓動

vi /etc/systemd/system/demoNetCore.service

複製代碼

[Unit]
Description=AspnetCoreDemo running on Centos8

[Service]# 應用程序所在的文件目錄
WorkingDirectory=/www/wwwroot/demo.cn/
ExecStart=/usr/share/dotnet/dotnet /www/wwwroot/demo.cn/Jb.Web.dll
Restart=always
# 如果dotnet服務崩潰,10秒後重新啓動服務
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=AspNetCoreDemo
User=root
#Production:生產環境 Development:開發環境
Environment=ASPNETCORE_ENVIRONMENT=Development
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

複製代碼
# 重載系統
systemctl daemon-reload
# 開機自啓動
systemctl enable aspnetCore.service

2.使自啓動生效
systemctl enable demoNetCore.service

3.立即啓動項目服務
systemctl start demoNetCore.service

systemctl stop demoNetCore.service
systemctl restart demoNetCore.service
systemctl list-units --type=service

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章