I'm trying to run my asp .net core app as a service under Ubuntu 16.04. I've created service configuration following this documentation
[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
I've enabled my service:
sudo systemctl enable tnw.service
And finally I've tried to run it but I obtain exception:
● 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'.
When I run this app manually it works fine.
sudo dotnet Tnw.MealsApi.dll
//Edit I've found in journal following exception:
System.Net.Sockets.SocketException (13): Permission denied