美文网首页netcore 实用技巧
linux 下netcore程序开机自动启动服务

linux 下netcore程序开机自动启动服务

作者: DemonTutor | 来源:发表于2020-07-28 16:23 被阅读0次

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

相关文章

网友评论

    本文标题:linux 下netcore程序开机自动启动服务

    本文链接:https://www.haomeiwen.com/subject/fvofrktx.html