[systemd-devel] Examples to distinguish Before=/After= and Wants=/Requires=/BindsTo=

Lennart Poettering lennart at poettering.net
Fri Sep 17 09:49:59 UTC 2021


On Mi, 15.09.21 17:15, Manuel Wagesreither (ManWag at FastMail.FM) wrote:

> Hello all,
>
> I'm onboarding some collegues who don't have much experience with
> systemd. One thing I would like to focus on is the difference
> between Before=/After= and Wants=/Requires=/BindsTo in systemd
> units.
>
> I think it would get immediately clear if could provide them an
> example where we want one but not the other. Unfortunately I've got
> problems coming up with such an example. In my use cases, whenever I
> needed an After= I needed an Wants= as well.
>
> Can you come up with something good?

Whenever you have a conceptually "weak" dependency between to
packages, i.e. both services can work alone, but they can also wor
together, and if so, one should be ordered after the other.

more specific example: you can use apache without mysql, and you can
use mysql without apache, but quite often they are used together, and
if so you likely want to start mysql first, and apache second, since
it likely consumes services of mysql, and not the other way
round. Hence in this example, you'd place an ordering dep, but not
requirement dep.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list