[systemd-devel] need help implementing a special behaviour

Lennart Poettering lennart at poettering.net
Tue Jul 8 05:22:01 PDT 2014


On Tue, 08.07.14 14:11, Steffen Sledz (sledz at dresearch-fe.de) wrote:

> 
> On 08.07.2014 13:53, Lennart Poettering wrote:
> > On Tue, 23.07.13 08:05, Steffen Sledz (sledz at dresearch-fe.de) wrote:
> >> ... 
> >> But we found no way to guarantee that *all* services of the formerly
> >> active operation mode (except the ones which should run in the new
> >> mode too) are *completely terminated* before the services of the new
> >> mode *begin to start*.
> > 
> > This is not available as global switch. You'd have to order the units
> > individually against each other, with After= or Before=.
> > 
> > Note that After= and Before= would actually have the *same* effect here,
> > as the general rule how they are executed is like this:
> > 
> >    With two units, A and B where B has After=A set:
> > 
> >    1) If the two units are started up, then B is started after A.
> > 
> >    2) If the two units are shut down, then A is stopped after B. (The rule
> >    is: the shutdown order is the inverse of the startup order).
> > 
> >    3) If A is stopped, and B is started, then A is stopped first, and then
> >    B is started.
> > 
> >    4) If B is stopped, and A is started, then A is also stopped first, and
> >    then B is started. (The rule is: when two units are ordered against
> >    each other, and one is started the other stopped, then the stop is
> >    *always* executed before the start, regardless in which way they are
> >    ordered).
> > 
> > But yeah, I can see that you are look for a simple global option here,
> > but this doesn't exist, and I am not sure how we could implement that. 
> 
> Thanx for this clarification.
> 
> There is one more open question. We did not found a *clear* definition
> (e.g. a state diagram) of all the states a unit can have.

Yeah, I tried to avoid documenting this in too much detail, since we
wanted to have the freedom to still alter the state machine if we need
to.

> e.g. What is the criteria for a service to change from *activating* to *active/started*?

That depends on the service Type= you have chosen, and whether you have
ExecStartPre= and/or ExecStartPost= commands for your service. "Active"
is entered basically after everything needed to start up a service is
executed plus the service has reported back that it is up. "Everything
needed" means ExecStartPre= and ExecStartPost= having been executed. And
the "reporting back" refers to the notification logic you chose with
Type=. See systemd.service(5) for more information about that.

Hope that makes some sense?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list