应用弄好了,怎么部署到LINUX服务器上让它以一个服务的形式跑起来呢?下面我来详细说说。
- 首先,当然是upload到服务器并解压
- 然后,生成一个systemctl配置脚本
sudo touch /etc/systemd/system/hostdemo.service
写入配置信息如下:
[Unit]
Description=Generic Host Demo
[Service]
#应用根目录
WorkingDirectory=/var/service/hostdemo
#执行脚本
ExecStart=/usr/bin/dotnet /var/service/hostdemo/HostService.dll --environment Production
KillSignal=SIGINT
#服务日至标识
SyslogIdentifier=host-demo-service
[Install]
WantedBy=multi-user.target
- 最后,启动服务
#启动服务
systemctl start hostdemo.service
#设置开机启动服务
systemctl enable hostdemo.service
#取消开机启动服务
systemctl disenable hostdemo.service
#重启服务
systemctl restart hostdemo.service
#关闭服务
systemctl stop hostdemo.service
#查看服务运行状态
systemctl status hostdemo.service
嗯,就是这么简单~