I am having a weird problem, I have set up a custom systemd service running a dotnet project. When the system first starts up, the service also starts just fine, however when I restart it, it hangs.
System is Ubuntu 20.04 on Azure.
Here's the service description:
[Unit]
Description=Api
[Service]
WorkingDirectory=/home/aviad/Backend
ExecStart=/snap/bin/dotnet run -c AzureDev --launch-profile AzureDev
Restart=always
RestartSec=10
User=aviad
[Install]
WantedBy=multi-user.target
This is the result of sudo systemctl status api
● api.service - Api
Loaded: loaded (/etc/systemd/system/api.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-09-14 15:51:50 UTC; 29min ago
Main PID: 855 (dotnet)
Tasks: 39 (limit: 9513)
Memory: 314.2M
CGroup: /system.slice/api.service
├─ 855 /snap/dotnet-sdk/120/dotnet run -c AzureDev --launch-profile AzureDev
└─2408 /home/aviad/Backend/bin/AzureDev/net5.0/Backend
And this is the status after a restart:
● api.service - Api
Loaded: loaded (/etc/systemd/system/api.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-09-14 16:33:33 UTC; 7s ago
Main PID: 8373 (dotnet)
Tasks: 0 (limit: 9513)
Memory: 460.0K
CGroup: /system.slice/api.service
‣ 8373 /snap/dotnet-sdk/120/dotnet run -c AzureDev --launch-profile AzureDev
Sep 14 16:33:33 machine1 systemd[1]: Started Api.
Apart from the bad status, the actual project doesn't really run.
Some more things I tried and had the same (bad) result:
- Stop the service, wait a while, then start it
- Disable the service, wait a while, then enable it
- Do the above after and before a
systemctl daemon-reload
- Issued a
kill -9
to the process id and let systemd
restart it