1.发布Linux程序包。上传至服务器。
2.在/etc/systemd/system/路径下添加 ServiceName.service文件并写入一下内容()
[Unit]
Description=orderserviceceshi
[Service]
Type=simple
#工作路径
WorkingDirectory=/home/data/orderserviceceshi
#执行的服务的dll文件
ExecStart=/usr/bin/dotnet /home/data/orderserviceceshi/OrderServiceceshi.dll
Restart=always
User=root
[Install]
WantedBy=multi-user.target
3.一下使用命令
重新加载配置文件:
sudo systemctl daemon-reload
启动:
sudo systemctl start ServiceName
停止:
sudo systemctl stop ServiceName
查看服务状态:
sudo systemctl status ServiceName
开机自启:
sudo systemctl enable ServiceName
关闭自启:
sudo systemctl disable ServiceName
查看服务日志:
sudo journalctl -u ServiceName
清理日志:
sudo journalctl --vacuum-time=1h
列出所有的服务:
systemctl list-units --type=service