0

I am getting the following error:

Jun 03 06:41:04 {my_digital_ocean_server} systemd[13752]: kestrel-hellomvc.service: Failed at step CHDIR spawning /usr/bin/dotnet: No such file or directory
-- Subject: Process /usr/bin/dotnet could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/bin/dotnet could not be executed and failed.

When running:

systemctl start kestrel-hellomvc.service

following this guide: https://learn.microsoft.com/en-us/aspnet/core/publishing/linuxproduction

Running: nano /usr/bin/dotnet gets me a large file with content, and which dotnet returns /usr/bin/dotnet, so the file does exist(?).

Why am I getting this error, and what is the solution?

EDIT: My /etc/systemd/system/kestrel-hellomvc.service file:

[Unit]
Description=Example .NET Web API Application running on Ubuntu

[Service]
WorkingDirectory=/var/aspnetcore/hellomvc
ExecStart=/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll
Restart=always
RestartSec=10  # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production 

[Install]
WantedBy=multi-user.target
Nixxon
  • 767
  • 1
  • 11
  • 24

2 Answers2

1

Dotnet might not be located in usr/bin. On Ubuntu Server 16.04 mine is located at /usr/share/dotnet and the executable line in the service file is /usr/share/dotnet/dotnet.

sqlsolver
  • 91
  • 4
1

Do

which dotnet

to find the correct path for your app service file /etc/systemd/system/kestrel-MyAppName.service attribute

ExecStart=/bin/dotnet /var/www/dev-slc1.almw.local/public_html/MyAppName.dll

For example on CentOS7 which dotnet results in above: /bin/dotnet.

u32i64
  • 2,384
  • 3
  • 22
  • 36