skip to Main Content

I’m trying to install .NET Core(3.1) app in Centos8 using steps given in MS enter .

Service File as per Microsoft document /etc/systemd/system/kestrel-dotnetapp.service

[Unit]  
Description= .NET Web API App for centos

[Service]
WorkingDirectory=/var/Application/netcoreapp31
ExecStart=/usr/local/dotnet /var/Application/netcoreapp31/helloapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:  
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnetapp
User=user
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

When i do > sudo systemctl start kestrel-dotnetapp.service am getting error.

Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed to execute command: Permission denied
Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed at step EXEC spawning /usr/local/dotnet: Permission denied
— Subject: Process /usr/local/dotnet could not be executed
— Defined-By: systemd

Find below ls -la :

[user@hostname dotnet]$ ls -la
total 108
drwxr-xr-x.  4 root root    94 Apr 22 09:34 .
drwxr-xr-x. 14 root root   154 Jun  4 21:11 ..
-rwxr-xr-x.  1 root root 73048 Apr 22 09:32 dotnet
drwxr-xr-x.  3 root root    17 Apr 22 09:34 host
-rw-r--r--.  1 root root  1116 Apr 22 09:29 LICENSE.txt
drwxr-xr-x.  4 root root    67 Apr 22 09:34 shared
-rw-r--r--.  1 root root 31330 Apr 22 09:29 ThirdPartyNotices.txt

My application deliverables folder

[user@hostname Application]$ ls -la
total 8
drwxr-xr-x.  3 root root     26 Jun  4 20:53 .
drwxr-xr-x. 22 root root   4096 Jun  4 20:53 ..
drwxr-xr-x.  2  777 user 4096 Jun  4 20:45 netcoreapp31

2

Answers


  1. Chosen as BEST ANSWER

    Found that service is starting when we change path of ExecStart to ExecStart=/usr/local/dotnet/dotnet . No idea why microsoft blog said till ExecStart=/usr/bin/dotnet is enough !

    PS: Also if the Linux is SE service files shouldn't be in /home directory


  2. After hours and hours of searching… the answer above is valid
    even for Dotnet 5.0 application with default installation and default user pi with custom publish folder:

    [Service]
     
    WorkingDirectory=/home/pi/myPublishDirectory
    
    ExecStart=/home/pi/.dotnet/**dotnet** /home/pi/myPublishDirectory/MyApplication.dll
    
    User=pi
    ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search