Linux CentOS创建webapi守护进程

创建文件:/etc/systemd/system/netcoreapi.service

 

以下是应用的一个示例服务文件:

[Unit]
Description=MyWebAPI

[Service]
WorkingDirectory=/netcore/api
ExecStart=/usr/bin/dotnet /netcore/api/webAPI.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
systemctl enable netcorewebapi.service --启用服务
systemctl start netcorewebapi.service --启动服务
systemctl stop netcorewebapi.servicee --停止服务
systemctl status netcorewebapi.service --查看状态
journalctl -fu netcorewebapi.service --查看日志

参考资料: 使用 Nginx 在 Linux 上托管 ASP.NET Core

posted @ 2020-12-02 17:09  金卧古梁  阅读(268)  评论(0)    收藏  举报