1.服務存放路徑(/usr/lib/systemd/system/) --》新建文件(crazybuild.service)
/usr/lib/systemd/system/crazybuild.service
2.文件內容
[Unit]
Description=CrazyWeb service? //服務描述
[Service]
WorkingDirectory=/www/wwwroot/netcore/ProjectBuilde/? //程序工作路徑
//啟動命令:dotnet -->/usr/bin/dotnet?
ExecStart= /usr/bin/dotnet /www/wwwroot/netcore/ProjectBuilde/CrazyWeb.Api.dll?
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
[Install]
WantedBy=multi-user.target
------------服務 啟動命令----
//啟動服務
systemctl start? crazybuild.service
//設置服務為開機自啟動
systemctl enable?crazybuild.service