2

I create a service in /etc/systemd/system as follow :

$ cd /etc/systemd/system
$ sudo nano test.service

Add the following content

[Unit]
Description=test app

[Service]
WorkingDirectory=/var/www/test-app
ExecStart=/usr/bin/dotnet /var/www/test-app/Test.App.dll
Restart=always
RestartSec=10
SyslogIdentifier=test
User=ubuntu
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

after save the service run following commands

$ sudo systemctl enable test.service
$ sudo systemctl start test.service
$ sudo systemctl status test.service

but display this error

test.service - test app
   Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2020-02-15 10:41:19 UTC; 8s ago
  Process: 24631 ExecStart=/usr/bin/dotnet /var/www/test-app/Test.App.dll (code=exited, status=200/CHDIR)
 Main PID: 24631 (code=exited, status=200/CHDIR)

The user (ubuntu) is exist and have proper ownership of the app's files

2 Answers 2

6

I had the same exact issue. I tried permissions, path length, using different directories. But the issue was a small mistake in the Working Directory path. Fixed, and all worked well.

2
  • What was the mistake in the Working Directory path?
    – CurtisHx
    Jul 16, 2020 at 21:19
  • Misspelled name of one of the directories of the path, i.e. the provided path to the .NET app was not correct. I don't know why my answer was downvoted. When I had this issue I spent time investigating it while I'm sure my configs are OK, but found this small mistake to fix it. Jul 20, 2020 at 10:56
0

Simply wrong directory path or don't permission to the directory. I have tested with root user on centos for Kestrel riht now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.