Linux的Daemon管理路径:
cd /etc/systemd/system
新建一个service配置文件:
vi my-auth.service
vi编辑器中编写的配置信息:
[Unit]
Description=Auth .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/home/auth
ExecStart=/usr/bin/dotnet /home/auth/AuthServer.Host.dlll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
SyslogIdentifier=my-auth
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
退出并保存vi
wq
刷新daemon让配置生效
systemctl deamon-reload
查看所有.net core进程
ps -ef|grep dotnet
查看服务状态
systemctl status my-auth
停止或重启服务
systemctl stop my-auth
systemctl restart my-auth