[systemd-devel] Services with multiple pre-requisites

freedesktop at priatel.co.uk freedesktop at priatel.co.uk
Wed Dec 23 10:29:28 UTC 2020


>> The third.service started as soon as *either* the first.target or 
>> second.target was started, even though it has *both* of them as 
>> Requisites, and as previously quoted, the manual, 
>> https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Req
>> uisite
>> =, says:
>>   | Requisite=
>>   |
>>   |     Similar to Requires=. However, if the units listed here are not
>>   |     started already, they will not be started and the starting of
>>   |     this unit will fail immediately.
>>
>> Bluntly, that does not appear to be true. It is a documentation bug, 
>> or at least poorly worded.
>
> Bluntly, maybe actually read what the docs say. Exactly one sentence after
the one
> you quoted you find this:
>
>    Requisite= does not imply an ordering dependency, even if both
>    units are started in the same transaction. Hence this setting
>    should usually be combined with After=, to ensure this unit is not
>    started before the other unit.
>
>> If first.target is started (which has Wants=third.service), but 
>> second.target is not, then how is it that third.service's 
>> "Requisite=second.target" does not cause "the starting of 
>> third.service to fail immediately"?
>>
>> Following Andrei's suggestion, I changed third.service to:
>
> Maybe just read the docs, more then two sentences.
>
> I mean, the docs certainly can use improvement. Everyhing can. But humm,
> the docs don't need "fixing", they aren't broken. They suggest exactly
> what to do.

Sorry, but the docs, and the behaviour here, make ZERO sense to me.

Recall that I had:
  #----- /etc/systemd/system/first.target -----#
  [Unit] Description=Started first
  Wants=third.service

  #----- /etc/systemd/system/second.target -----#
  [Unit] Description=Started second
  Wants=third.service

  #----- /etc/systemd/system/third.service -----#
  [Unit] Description=Third service
  Requisite=first.target second.target

I explicitly started first.target **AND NOTHING ELSE**.

It therefore looks like systemd has disregarded "Requisite:second.target".

Regardless of ordering dependencies, the statement "the starting of this
unit will fail immediately" is simply not true.

The manual has:
  | Requisite= does not imply an ordering dependency, even if both
  | units are started in the same transaction.

The issue here is that if I don't start second.target *AT ALL*,
third.service is still started, even though it has second.target as a
Requisite.

Please explain to me under what circumstances "the starting of this unit
will fail immediately" will occur. IF the answer to that is "only if you
also use After" (which is what you seem to be implying) -- then we're
back to this being a doc bug, since "should usually" is not the same as
"only if". The doc does not say "the starting of this unit will fail
immediately if there is also an ordering dependency".

Martin



More information about the systemd-devel mailing list