How to restart a systemctl service from within the process
Colin Law
clanlaw at gmail.com
Sun Nov 22 11:54:32 UTC 2020
On Sun, 22 Nov 2020 at 11:14, Karl Auer <kauer at biplane.com.au> wrote:
>
> On Sun, 2020-11-22 at 09:45 +0000, Colin Law wrote:
> > I have a service (a nodejs process running node-red) and want it to
> > self-restart. The obvious way appears to be to invoke
> > systemctl restart theservice
>
> Oh, to add to my previous response (sorry) I mean that to restart the
> service from inside the service you simply exit the service, and let
> systemd restart it. Not sure if the exit value is relevant.
Yes it is, that determines whether it is a failure or not and
therefore affects what the restart= option sees. I am not sure there
is any way of telling node-red to exit, plus I don't really want to
have to override the standard service file for node-red
>
> > but I am concerned about the fact that the process running the
> > systemctl command will itself be killed as part of the restart
>
> Pretty sure it won't be. But if you discover that there is a problem,
> do let us know :-)
I am pretty sure it won't be a problem too, as I hope this is
something that the s/w designers thought of, but there is no way to be
certain of that unless one knows how it works. I can test it
certainly, but if there is a possible race condition then either it
may fail very occasionally or may not fail at all until I deploy it to
a different system or some system updates or something, so just
because it seems to work does not mean it will always work.
Colin
More information about the ubuntu-users
mailing list