我正在尝试在Ubuntu 16.04下将我的asp.net core应用程序作为服务运行。 我按照这份文档创建了服务配置。
[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