我正在尝试在 Ubuntu 16.04 下将我的 asp .net core 应用程序作为服务运行。
我创建了以下服务配置this https://learn.microsoft.com/pl-pl/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2文档
[Unit]
Description=TNW Main Service
[Service]
WorkingDirectory=/home/tnw
ExecStart=/usr/bin/dotnet /home/tnw/Tnw.MealsApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=tnw
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
我已启用我的服务:
sudo systemctl enable tnw.service
最后我尝试运行它,但出现异常:
● tnw.service - TNW Main Service Loaded: loaded (/etc/systemd/system/tnw.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: core-dump) since Tue 2019-09-10 12:57:20 CEST; 118ms ago
Process: 15160 ExecStart=/usr/bin/dotnet /home/tnw/Tnw.MealsApi.dll (code=dumped, signal=ABRT)
Main PID: 15160 (code=dumped, signal=ABRT)
Sep 10 12:57:20 server767126 systemd[1]: tnw.service: Unit entered failed state.
Sep 10 12:57:20 server767126 systemd[1]: tnw.service: Failed with result 'core-dump'.
当我手动运行这个应用程序时,它工作正常。
sudo dotnet Tnw.MealsApi.dll
//编辑我在日志中发现以下异常:
System.Net.Sockets.SocketException (13): Permission denied
就我而言,原因是程序启动时出现异常。我用这个命令找到了它:journalctl -f
.
另外,建议将程序启动包装为try
例如,使用 Serilog 阻止并将错误记录到文件中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)