I have an ASP.NET Core web app on an Ubuntu VM that I’m trying to run on boot (following these docs). When I start my systemd service my app fails to run and I get this error:
kestrel-myapp.service: Changing to the requested working directory failed: No such file or directory
I’m a bit confused because I’ve verified that the path in the .service
file exists and I’ve changed the directory’s owner to the www-data
user (I’m using nginx) with chmod 750
permissions.
Here’s my .service file:
[Unit]
Description=MyApp Test
[Service]
User=www-data
WorkingDirectory=/var/www/myapp/Release/net8.0/publish/
ExecStart=/usr/bin/dotnet /var/www/myapp/Release/net8.0/publish/MyApp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_NOLOGO=true
# The default value is 90 seconds for most distributions.
TimeoutStopSec=90
[Install]
WantedBy=multi-user.target
Thanks for the help