dotnet core webapi centos 服务自启动

centos + .NET Core 3.1 Web API

  1. 进入目录cd /lib/systemd/system/

  2. 在目录下创建.service文件vi yjwebapiserver.service

  3. 编辑

[Unit]
Description=api service
After=network.target
[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/home/api/publish/
StandardOutput=journal
StandardError=journal
ExecStart=/usr/dotnet-sdk/dotnet /home/api/publish/YJZH.Api.dll &
Restart=always
[Install]
WantedBy=multi-user.target

4.启动systemctl start yjwebapiserver.service

5.设置开机自启systemctl enable yjwebapiserver.service

6.查看状态systemctl status yjwebapiserver.service

7.查看服务启动项systemctl list-unit-files

posted @ 2021-06-16 22:37  gisliuliang  阅读(293)  评论(0编辑  收藏  举报