centos + .NET Core 3.1 Web API
-
进入目录
cd /lib/systemd/system/
-
在目录下创建.service文件
vi yjwebapiserver.service
-
编辑
[Unit]
Description=api service
After=network.target
[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/home/api/publish/ #api发布路径
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