2

I have 2 systemd units to configure. They both require config files set at specific locations (each with their own config location), so they are both configured with ConditionPathExists for their respective configuration files.

They conflict with one another on account of listening on the same port. So they are also configured with Conflicts=

However, in the case where both config files are present (which should not happen under normal circumstances, but might), I would like service A to start and not service B. What should I configure for that purpose?

2 Answers 2

2

If both units are queued and everything else is equal (i.e. both units are pulled in through equal Wants= dependencies), then the unit that has Conflicts= will be the one started, while the "conflicted by something else" unit will be skipped.

1

I am not aware of any precedence configuration within Systemd but you can achieve the aim with Systemd features.

# a.service
ConditionPathExists=/path/to/configfile.a
# b.service
ConditionPathExists=!/path/to/configfile.a
ConditionPathExists=/path/to/configfile.b

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .