>>> "Pagliari, Vivenzio (Nokia - DE/Ulm)" <vivenzio.pagli...@nokia.com> schrieb
am
17.09.2021 um 09:52 in Nachricht
<am8pr07mb8309bc4cda893e374fbef552ee...@am8pr07mb8309.eurprd07.prod.outlook.com>

> Hello Manuel,
> 
> my experience is that it is helpful for people new to systemd to "raise the

> right question" that is answered by the corresponding relationship between 
> systemd units.
> 
> The question "*if* a unit shall be started/enqueued" is answered 
> Wants=/Requires=/BindsTo relation. I call this the "dependency relation". To

> know "*when* a unit shall be started/enqueued, you need to consider the 
> Before=/After= relation. I call this is the "time order relation". It is 
> pretty obvious, that a time order relation only makes sense, of you have a 
> dependency relation as well. The other way round it is different: it may
make 
> sense that some unit A wants some other unit B, but there is no time
ordering 
> between them.
> 
> If you have some "mathematically inclined" people whom you want to describe

> it: Given a set A of all systemd units on your computer, you have the
special 
> unit default.target (or the one passed on the kernel command line with the 
> systemd.unit parameter) which forms the root of a "dependency tree", given
by 
> the Requires/Wants relations. This tree forms the subset B of systemd units

> on your computer to be started/enqueued at boot time. This set B of systemd

> units is a partially ordered set: Some (but not all) of the elements have a

> (time) order relation, by which they can be (topologically) sorted. This is

> then the order in which the units are enqueued. Note that this order is not

> "fix", there can be different "total orderings" of a partially ordered set.

Yes, what makes things more complicated is that "After X" actually means
"NotBefore X" (i.e. "at some later time" and not "immediately after X"), and
"Before" means "NotAfter".
Combined with the swapped roles on system startup/shutdown, it can be rather
tricky sometimes to get things right.

Regards,
Ulrich

> 
> HTH
> Vivenzio
> 
> ‑‑‑‑‑Original Message‑‑‑‑‑
> From: systemd‑devel <systemd‑devel‑boun...@lists.freedesktop.org> On Behalf
Of 
> Manuel Wagesreither
> Sent: Wednesday, September 15, 2021 5:16 PM
> To: SystemD Devel <systemd‑de...@lists.freedesktop.org>
> Subject: [systemd‑devel] Examples to distinguish Before=/After= and 
> Wants=/Requires=/BindsTo=
> 
> 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?
> 
> Thanks, regards,
> Manuel



Reply via email to