[systemd-devel] restart vs. stop/start

Lennart Poettering lennart at poettering.net
Mon May 23 09:24:06 UTC 2016


On Fri, 20.05.16 21:50, Christian Boltz (systemd-devel at cboltz.de) wrote:

> Hello,
> 
> it looks like
>     systemctl restart foo
> is internally mapped to a sequence of
>     systemctl stop foo; systemctl start foo
> 
> Unfortunately, this behaviour causes quite some trouble for me.
> 
> I need a way to know if "restart "or "stop" was used because the mapping 
> to stop / start gives my service a completely different behaviour than 
> expected on restart.

We don't support that as our logic permits merging of jobs. This means
that if two clients enqueue two stop or two start jobs at the same
time, then we will only actually run one. In fact, this merging of
jobs goes even further: restart and start can be merged. And that
means there's really no clear concept of "My service is being stopped
for a restart", as your service might actually be stopped on request
of 7 clients, where 4 wanted to start it, 1 wanted to stop it, and 2
wanted to restart it....

> Is there a way to find out if "stop" or "restart" was used?

No, not really... Except that you could misuse the fd store logic for
this, as you already found out...

Usually mapping issues like what you are running into indicate though
that the mapping is skewed, and you are trying to make the "restart"
verb something that the "reload" verb actually exists for.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list