服务器:Ubuntu
以服务方式运行项目
1、进入目录
cd /etc/systemd/system
2、新建一个文件
vim test.service
内容:
[Unit]
Description= {Project Description}
[Service]
WorkingDirectory=/home/test/test_pro #项目所在的文件夹
ExecStart=/home/test/test_pro/run #项目启动文件
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=douyin and kuaishou video upload
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=ASPNETCORE_URLS=http://localhost:8762 #运行在哪个端口
[Install]
WantedBy=multi-user.target
保存文件
3、重新加载
sudo systemctl daemon-reload
4、启用服务
sudo systemctl enable test.service
5、开始
sudo systemctl start test.service
6、查看运行日志
journalctl -fu test.service
7、停止运行
sudo systemctl stop test.service