[systemd-devel] restart vs. stop/start
Christian Boltz
systemd-devel at cboltz.de
Mon May 23 20:45:32 UTC 2016
Hello,
Am Montag, 23. Mai 2016, 11:24:06 CEST schrieb Lennart Poettering:
> On Fri, 20.05.16 21:50, Christian Boltz wrote:
> > 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....
I'm mostly interested in catching manual restarts done by an admin (the
RPM %post scripts already use reload as they should [1]), so this
wouldn't be a problem.
> > 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...
So you are saying that I'll need to add a small keep-the-fd-open daemon
to find out if restart was used?
I'm not too keen on doing this, and would really like to have an
"official" way to find this out. Especially since systemd already knows
this, so making that information available to the service should be
trivial.
> 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.
You are right that "reload" is what people _should_ use.
However, as I already wrote in another mail, accidently using "restart"
will make the system insecure, so I'd like to change the restart
behaviour to do something sane (for AppArmor, it should reload the
profiles).
Regards,
Christian Boltz
[1] I had to override the default RPM macros for that ;-)
--
[checkinstall] is a tool that allows you to keep your
brain in suspend mode. [Robert Schiele in opensuse]
More information about the systemd-devel
mailing list