Am Mi, 15. Sep 2021, um 19:23, schrieb Andrei Borzenkov:
> On 15.09.2021 18:15, Manuel Wagesreither 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?
> >
>
> No. B After A means - select start job for B for execution after start
> job for A completes. This directive is only meaningful if you guarantee
> that both start jobs are present in the queue. And the only way to
> ensure it is to use Wants (or Requires as variant).
>
> If service B really needs service A to be started before it itself can
> be started, you must use After and Wants, otherwise you are open to race
> conditions. And if service B does not care if service A is started, then
> you do not need After in the first place.
>
> Of course one can try to ensure that all start jobs are present in queue
> by some external means. Like making all units to be WantedBy some
> super-unit which is called ... default.target (surprise). But that does
> not change underlying requirement, just restricts working case to
> starting one single unit. Presumably on system boot :)
>
I understand. Still, I'm looking for giving the people I teach an example why
it made sense to implement it this way. Something else than just saying "that's
just how it is, just accept it".