[systemd-devel] systemd service start/stop conditions

Lennart Poettering lennart at poettering.net
Tue Jul 8 04:58:15 PDT 2014


On Tue, 08.07.14 13:00, Mario Schuknecht (mario.schuknecht at dresearch-fe.de) wrote:

> I have the following problem:
> There are 3 (or more) systemd targets. Each of the three targets starts a
> number of systemd services.
> It can be switched back and forth between the systemd targets.
> 
> As a limitation, it is necessary that the services of a target start only
> if the services of actual target are already stopped. Because there have
> resources to be released, such as a serial port.
> 
> The problem is solved with Unit paramter Conflicts. Starting a target will
> stop the other.

I figure your colleague already asked the same question. But long story
short: you cannot solve this purely by ordereing only the targets. You
need Conflicts= and After= (or Before=) between the actual service units
that shall be exclusive to each other. More specifically, if you have
two units accessing the same serial port, then they should have
Conflicts= as well as After= (or Before=).

Also see other mail for the more theoretic background of this.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list