Netcore服务生成说明
如有个项目/opt/wwwroot/dpms.1633.com
启动为/usr/bin/dotnet /opt/wwwroot/dpms.1633.com/DPMS.Web.dll
后台启动为nohup /usr/bin/dotnet /opt/wwwroot/dpms.1633.com/DPMS.Web.dll &
每次更新启动都很麻烦,现在做出服务用centos的命令启动和重启
###-------------------------------复制以下命令并进行更改,生成自己需要的服务
cat >>/usr/lib/systemd/system/patent.service<<EOF
[Unit]
Description=patent program on centos7
[Service]
WorkingDirectory=/opt/wwwroot/api-patent.1633.com
ExecStart=/usr/bin/dotnet /opt/wwwroot/api-patent.1633.com/Patent.Web.dll
Restart=always
RestartSec=10
User=root
SyslogIdentifier=dotnet-patent
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
EOF
###-------------------------------------
---------------------------
#服务配置好后,用以下命令启动,dpms.service按各自项目更改
systemctl enable dpms.service #开机启动
systemctl start dpms.service #启动
systemctl restart dpms.service #重启
systemctl stop dpms.service #停止
systemctl status dpms.service #检查服务状态 running表示服务器正在运行,fail表示程序出错
systemctl list-units --type=service #列出所有的服务