[systemd-devel] need help implementing a special behaviour
Lennart Poettering
lennart at poettering.net
Tue Jul 8 04:53:48 PDT 2014
On Tue, 23.07.13 08:05, Steffen Sledz (sledz at dresearch-fe.de) wrote:
> We like to implement the following behaviour using systemd.
>
> We have some exclusive so called operating modes. Each modes has a few
> associated services which should run in this mode.
Yeah, this should work. You should be able to define target units and
then use "isolate" to switch between them. Or you define the targets and
add Conflicts= to all the other units you want to kick out, which allows
you to use "start" on the target, instead of "isolate".
> Our idea is to define some conflicting targets representing the
> operation modes.
>
> 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.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list