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

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