把dotnet也变成一个像mysql,nginx一样的后台服务,就可以用systemctl来管理了
代码语言:javascript复制# 编辑配置文件
vim /usr/lib/systemd/system/ZhaiFanhuaImage.service
输入
代码语言:javascript复制[Unit]
Description=ZhaiFanhuaImage
[Service]
WorkingDirectory=/home/web/zhaifanhua.com/demo/ZhaiFanhuaImage/
ExecStart=dotnet /home/web/zhaifanhua.com/demo/ZhaiFanhuaImage/ZhaiFanhuaImage.dll --urls="http://*:9708" --ip="127.0.0.1"
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=ZhaiFanhuaImage
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
进程守护
代码语言:javascript复制# -----------进程守护-----------------
# 更新配置
systemctl daemon-reload
# 设置开机自启动
systemctl enable ZhaiFanhuaImage
# 停止开机自启动
systemctl disable ZhaiFanhuaImage
管理命令
代码语言:javascript复制# -----------管理命令-----------------
# 启动服务
systemctl start ZhaiFanhuaImage
# 停止服务
systemctl stop ZhaiFanhuaImage
# 重新服务
systemctl restart ZhaiFanhuaImage
# 查看状态
systemctl status ZhaiFanhuaImage
我的博客即将同步至腾讯云 社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=27a065d3u2zo8