[systemd-devel] Services with multiple pre-requisites
freedesktop at priatel.co.uk
freedesktop at priatel.co.uk
Tue Dec 22 15:24:15 UTC 2020
Lennart Poettering wrote:
> Martin wrote:
>> Ah. Thanks for the explanation. Adding
>> Wants=first.target second.target
>
> Hmm, what?
>
> After=/Before= are the ordering deps, Wants= is a requirement dep.
>
>> Respectfully suggest that the documentation bug should be fixed!
>
>I am sorry, what?
So, this did not work:
#----- /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
[Service]
<...>
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#Requisite
=, 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.
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:
#----- /etc/systemd/system/third.service -----#
[Unit]
Description=Third service
Requisite=first.target second.target
After=first.target second.target
[Service]
<...>
and it worked as I hoped.
Martin
More information about the systemd-devel
mailing list