From d19cd71a8a6dca4565d7d1c8766127b70c10ebe0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 6 Nov 2019 13:26:29 +0100 Subject: [PATCH] man: put description of Wants= above Requires= We want users to use Wants, but we'd describe Requires first and ask users to look for Wants instead. While at it, let's split the wall of text into sensible paragraphs: syntax first, followed by semantics and longer description, and finally hints and comparison to other configuration items last. --- man/systemd.unit.xml | 127 +++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 5acb595..1670992 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -556,21 +556,43 @@ + Wants= + + Configures requirement dependencies on other units. This option may be specified more + than once or multiple space-separated units may be specified in one option in which case dependencies + for all listed names will be created. Dependencies of this type may also be configured outside of the + unit configuration file by adding a symlink to a .wants/ directory accompanying + the unit file. For details, see above. + + Units listed in this option will be started if the configuring unit is. However, if the listed + units fail to start or cannot be added to the transaction, this has no impact on the validity of the + transaction as a whole, and this unit will still be started. This is the recommended way to hook + start-up of one unit to the start-up of another unit. + + Note that requirement dependencies do not influence the order in which services are started or + stopped. This has to be configured independently with the After= or + Before= options. If unit foo.service pulls in unit + bar.service as configured with Wants= and no ordering is + configured with After= or Before=, then both units will be + started simultaneously and without any delay between them if foo.service is + activated. + + + Requires= - Configures requirement dependencies on other units. If this unit gets activated, the units - listed here will be activated as well. If one of the other units fails to activate, and an ordering dependency - After= on the failing unit is set, this unit will not be started. Besides, with or without - specifying After=, this unit will be stopped if one of the other units is explicitly - stopped. This option may be specified more than once or multiple space-separated units may be - specified in one option in which case requirement dependencies for all listed names will be created. Note that - requirement dependencies do not influence the order in which services are started or stopped. This has to be - configured independently with the After= or Before= options. If a unit - foo.service requires a unit bar.service as configured with - Requires= and no ordering is configured with After= or - Before=, then both units will be started simultaneously and without any delay between them - if foo.service is activated. Often, it is a better choice to use Wants= - instead of Requires= in order to achieve a system that is more robust when dealing with + Similar to Wants=, but declares a stronger + dependency. Dependencies of this type may also be configured by adding a symlink to a + .requires/ directory accompanying the unit file. + + If this unit gets activated, the units listed will be activated as well. If one of + the other units fails to activate, and an ordering dependency After= on the + failing unit is set, this unit will not be started. Besides, with or without specifying + After=, this unit will be stopped if one of the other units is explicitly + stopped. + + Often, it is a better choice to use Wants= instead of + Requires= in order to achieve a system that is more robust when dealing with failing services. Note that this dependency type does not imply that the other unit always has to be in active state when @@ -580,11 +602,7 @@ example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not propagated to units having a Requires= dependency. Use the BindsTo= dependency type together with After= to ensure that a unit may never be in active state - without a specific other unit also in active state (see below). - - Note that dependencies of this type may also be configured outside of the unit configuration file by - adding a symlink to a .requires/ directory accompanying the unit file. For details, see - above. + without a specific other unit also in active state (see below). @@ -606,24 +624,6 @@ - Wants= - - A weaker version of - Requires=. Units listed in this option will - be started if the configuring unit is. However, if the listed - units fail to start or cannot be added to the transaction, - this has no impact on the validity of the transaction as a - whole. This is the recommended way to hook start-up of one - unit to the start-up of another unit. - - Note that dependencies of this type may also be - configured outside of the unit configuration file by adding - symlinks to a .wants/ directory - accompanying the unit file. For details, see - above. - - - BindsTo= Configures requirement dependencies, very similar in style to @@ -679,7 +679,7 @@ After= and Before= ordering dependencies. - If a unit A that conflicts with a unit B is scheduled to + If unit A that conflicts with unit B is scheduled to be started at the same time as B, the transaction will either fail (in case both are required parts of the transaction) or be modified to be fixed (in case one or both jobs are not a @@ -693,29 +693,36 @@ Before= After= - These two settings expect a space-separated list of unit names. They configure ordering - dependencies between units. If a unit foo.service contains a setting - and both units are being started, bar.service's - start-up is delayed until foo.service has finished starting up. Note that this setting is - independent of and orthogonal to the requirement dependencies as configured by Requires=, - Wants= or BindsTo=. It is a common pattern to include a unit name in both - the After= and Requires= options, in which case the unit listed will be - started before the unit that is configured with these options. This option may be specified more than once, in - which case ordering dependencies for all listed names are created. After= is the inverse of - Before=, i.e. while After= ensures that the configured unit is started - after the listed unit finished starting up, Before= ensures the opposite, that the - configured unit is fully started up before the listed unit is started. Note that when two units with an - ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is - configured with After= on another unit, the former is stopped before the latter if both are - shut down. Given two units with any ordering dependency between them, if one unit is shut down and the other is - started up, the shutdown is ordered before the start-up. It doesn't matter if the ordering dependency is - After= or Before=, in this case. It also doesn't matter which of the two - is shut down, as long as one is shut down and the other is started up. The shutdown is ordered before the - start-up in all cases. If two units have no ordering dependencies between them, they are shut down or started - up simultaneously, and no ordering takes place. It depends on the unit type when precisely a unit has finished - starting up. Most importantly, for service units start-up is considered completed for the purpose of - Before=/After= when all its configured start-up commands have been - invoked and they either failed or reported start-up success. + These two settings expect a space-separated list of unit names. They may be specified + more than once, in which case dependencies for all listed names are created. + + Those two setttings configure ordering dependencies between units. If unit + foo.service contains the setting and both + units are being started, bar.service's start-up is delayed until + foo.service has finished starting up. After= is the inverse + of Before=, i.e. while Before= ensures that the configured unit + is started before the listed unit begins starting up, After= ensures the opposite, + that the listed unit is fully started up before the configured unit is started. + + When two units with an ordering dependency between them are shut down, the inverse of the + start-up order is applied. i.e. if a unit is configured with After= on another + unit, the former is stopped before the latter if both are shut down. Given two units with any + ordering dependency between them, if one unit is shut down and the other is started up, the shutdown + is ordered before the start-up. It doesn't matter if the ordering dependency is + After= or Before=, in this case. It also doesn't matter which + of the two is shut down, as long as one is shut down and the other is started up; the shutdown is + ordered before the start-up in all cases. If two units have no ordering dependencies between them, + they are shut down or started up simultaneously, and no ordering takes place. It depends on the unit + type when precisely a unit has finished starting up. Most importantly, for service units start-up is + considered completed for the purpose of Before=/After= when all + its configured start-up commands have been invoked and they either failed or reported start-up + success. + + Note that those settings are independent of and orthogonal to the requirement dependencies as + configured by Requires=, Wants=, Requisite=, + or BindsTo=. It is a common pattern to include a unit name in both the + After= and Wants= options, in which case the unit listed will + be started before the unit that is configured with these options. -- 2.7.4