How to restart a systemctl service from within the process

Karl Auer kauer at biplane.com.au
Mon Nov 23 11:03:14 UTC 2020


On Mon, 2020-11-23 at 09:51 +0000, Colin Law wrote:
> On Mon, 23 Nov 2020 at 09:41, Karl Auer <kauer at biplane.com.au> wrote:
> > Not sure it will help you if node-red has to run as root.
> 
> It doesn't have to and it is definitely a bad idea to run node-red as
> root.  What gave you that idea?

I didn't say it did had to. I just thought that if it did, then having
your service be restartable by a non-root user would probably not be
much help, because the underlying service would still not be
restartable without sudo.

I'm guessing that the node-red service file has user and group lines in
it, so that the service runs as that user and group. That being so it
is possible for that user to kill the service - not via systemctl,
which will need sudo, but via a signal. And depending on the signal,
systemctl would then restart the service for you.

It just seems a tad Rube Goldbergish (or Heath Robinsonish if you are
from the other side of the Atlantic) to give a non-root user a sudoers
entry just so that it is able to use sudo to run systemctl to restart
some service. And it doesn't seem any less difficult a thing for the
unskilled user to accomplish than adding a line to a service file.

But I am keenly aware that I probably do not have all the facts. If you
have something that's working, that's the main thing.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer

GPG fingerprint: 2561 E9EC D868 E73C 8AF1 49CF EE50 4B1D CCA1 5170
Old fingerprint: 8D08 9CAA 649A AFEF E862 062A 2E97 42D4 A2A0 616D







More information about the ubuntu-users mailing list