Score:0

Ubuntu - force killing a service

ru flag

I've seen a few topics on this before on AskUbuntu and bits and pieces from other forums but no answer actually solved my query. I'm trying to kill a service on my Ubuntu machine via SSH (Terminal), here's the things that I've tried:

  • used systemctl kill [servicename]
  • used htop to kill the processes

Is there a way to edit the service file (possibly) so it'll kill the service instead of trying to shut it down (if that's the only way around it)?

The service uses uwsgi, using uwsgi.ini, and it runs on 5 processes which is why killing one doesn't kill it in the end.

After trying to kill it using htop or systemctl kill, it seems the processes respawn, or at least that is what I think is happening from my diagnostics. I'm trying to restart the service to apply the changes that I've made to the code, but annoyingly I can't due to ...this. Any help would be much appreciated.

I've also tried adding in Restart=always and RemainAfterExit=no to the service file but that didn't make a difference either.

Here's the service:

Description=uWSGI instance to serve live ver. of project
After=network.target

[Service]
User=root
Group=root
Restart=always
RemainAfterExit=no
WorkingDirectory=/var/www/project
Environment="PATH=/root/.pyenv/versions/3.7.2/envs/project/bin"
ExecStart=/root/.pyenv/versions/3.7.2/envs/project/bin/uwsgi --ini uwsgi.ini

[Install]
WantedBy=multi-user.target
vanadium avatar
cn flag
No way to tell anything sensible here without knowing the details of the service. Do you need to launch it in the first place? Perhaps just stop it from launching on bootup.
Nicholas Yoannou avatar
ru flag
Hi @vanadium, I’ll edit the post with details of the service. (What the service file looks like)
Nicholas Yoannou avatar
ru flag
@vanadium There we go, service added to post description. Should be able to see the service now.
ingank avatar
cn flag
I don't know anything about the uwsgi service. According to the [online documentation](https://uwsgi-docs.readthedocs.io/en/latest/Upstart.html), the daemon can be started with the option `--die-on-term`. This should make it possible to kill the process via SIGTERM.
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.