Score:0

systemd service starts ok, but hangs after restart

us flag

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:

  1. Stop the service, wait a while, then start it
  2. Disable the service, wait a while, then enable it
  3. Do the above after and before a systemctl daemon-reload
  4. Issued a kill -9 to the process id and let systemd restart it
Michael Hampton avatar
cz flag
Is there something unusual about your home directory?
Aviad P. avatar
us flag
Nothing that I have done knowingly
Aviad P. avatar
us flag
It appears that installing dotnet using snap is the problem. I removed it using snap and then installed it using apt and it now works...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.