From c129bd5df3ca08eb352cf69d01d2f374552624ae Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 11 Nov 2015 20:47:07 +0100 Subject: [PATCH] man: document automatic dependencies For all units ensure there's an "Automatic Dependencies" section in the man page, and explain which dependencies are automatically added in all cases, and which ones are added on top if DefaultDependencies=yes is set. This is also done for systemd.exec(5), systemd.resource-control(5) and systemd.unit(5) as these pages describe common behaviour of various unit types. --- man/systemd.automount.xml | 20 ++++++++++-- man/systemd.device.xml | 11 +++++++ man/systemd.exec.xml | 44 ++++++++++++++++++++++++--- man/systemd.mount.xml | 52 +++++++++++++++++++++++++++++--- man/systemd.path.xml | 17 +++++++++-- man/systemd.resource-control.xml | 9 ++++++ man/systemd.scope.xml | 9 ++++++ man/systemd.service.xml | 49 +++++++++++++++++++++--------- man/systemd.slice.xml | 8 +++++ man/systemd.socket.xml | 46 +++++++++++++++++++++++++--- man/systemd.swap.xml | 34 +++++++++++++++------ man/systemd.target.xml | 15 ++++++--- man/systemd.timer.xml | 32 +++++++++++++------- man/systemd.unit.xml | 33 +++++++++++++++----- 14 files changed, 312 insertions(+), 67 deletions(-) diff --git a/man/systemd.automount.xml b/man/systemd.automount.xml index 26a0f291dd..1b0ae832da 100644 --- a/man/systemd.automount.xml +++ b/man/systemd.automount.xml @@ -85,10 +85,24 @@ Automount units may be used to implement on-demand mounting as well as parallelized mounting of file systems. + + + + Automatic Dependencies + + If an automount unit is beneath another mount unit in the + file system hierarchy, both a requirement and an ordering + dependency between both units are created automatically. + + An implicit Before= dependency is created + between an automount unit and the mount unit it activates. + + Automount units acquire automatic Before= + and Conflicts= on + umount.target in order to be stopped during + shutdown, unless DefaultDependencies=no is + set. - If an automount point is beneath another mount point in the - file system hierarchy, a dependency between both units is created - automatically. diff --git a/man/systemd.device.xml b/man/systemd.device.xml index ac6deafb18..effed098dd 100644 --- a/man/systemd.device.xml +++ b/man/systemd.device.xml @@ -83,7 +83,18 @@ the escaping logic used to convert a file system path to a unit name see systemd.unit5. + + + Automatic Dependencies + + Many unit types automatically acquire dependencies on device + units of devices they require. For example, + .socket unit acquire dependencies on the + device units of the network interface specified in + BindToDevice=. Similar, swap and mount units + acquire dependencies on the units encapsulating their backing + block devices. diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 2b090871ff..6317830ae2 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -76,6 +76,31 @@ unit type. + + Automatic Dependencies + + A few execution parameters result in additional, automatic + dependencies to be added. + + Units with WorkingDirectory= or + RootDirectory= set automatically gain + dependencies of type Requires= and + After= on all mount units required to access + the specified paths. This is equivalent to having them listed + explicitly in RequiresMountsFor=. + + Similar, units with PrivateTmp= enabled + automatically get mount unit dependencies for all mounts + required to access /tmp and + /var/tmp. + + Units whose output standard output or error output is + connected to any other sink but , + and automatically + acquire dependencies of type After= on + journald.socket. + + Options @@ -93,7 +118,9 @@ and the respective user's home directory if run as user. If the setting is prefixed with the - character, a missing working directory is not considered - fatal. + fatal. Note that setting this parameter might result in + additional dependencies to be added to the unit (see + above). @@ -104,7 +131,9 @@ project='man-pages'>chroot2 system call. If this is used, it must be ensured that the process binary and all its auxiliary files are available in - the chroot() jail. + the chroot() jail. Note that setting this + parameter might result in additional dependencies to be added + to the unit (see above). @@ -351,6 +380,7 @@ This setting defaults to . + StandardOutput= Controls where file descriptor 1 (STDOUT) of @@ -416,8 +446,11 @@ This setting defaults to the value set with in systemd-system.conf5, - which defaults to . + which defaults to . Note that setting + this parameter might result in additional dependencies to be + added to the unit (see above). + StandardError= Controls where file descriptor 2 (STDERR) of @@ -428,8 +461,11 @@ standard error. This setting defaults to the value set with in systemd-system.conf5, - which defaults to . + which defaults to . Note that setting + this parameter might result in additional dependencies to be + added to the unit (see above). + TTYPath= Sets the terminal device node to use if diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml index dd6b7a51a8..67e96dc157 100644 --- a/man/systemd.mount.xml +++ b/man/systemd.mount.xml @@ -94,10 +94,6 @@ unit, to allow on-demand or parallelized mounting. See systemd.automount5. - If a mount point is beneath another mount point in the file - system hierarchy, a dependency between both units is created - automatically. - Mount points created at runtime (independently of unit files or /etc/fstab) will be monitored by systemd and appear like any other mount unit in systemd. See @@ -113,6 +109,52 @@ File Systems. + + Automatic Dependencies + + If a mount unit is beneath another mount unit in the file + system hierarchy, both a requirement dependency and an ordering + dependency between both units are created automatically. + + Block device backed file systems automatically gain + BindsTo= and After= type + dependencies on the device unit encapsulating the block + device (see below). + + If traditional file system quota is enabled for a mount + unit, automatic Wants= and + Before= dependencies on + systemd-quotacheck.service and + quotaon.service are added. + + For mount units with + DefaultDependencies=yes (the default) a couple + additional dependencies are added. Mount units referring to local + file systems automatically gain an After= + dependency on local-fs-pre.target. Network + mount units automatically acquire After= + dependencies on remote-fs-pre.target, + network.target and + network-online.target. Towards the latter a + Wants= unit is added as well. Mount units + referring to local and network file systems are distinguished by + their file system type specification. In some cases this is not + sufficient (for example network block device based mounts, such as + iSCSI), in which case may be added to the + mount option string of the unit, which forces systemd to consider the + mount unit a network mount. Mount units (regardless if local or + network) also acquire automatic Before= and + Conflicts= on + umount.target in order to be stopped + during shutdown. + + Additional implicit dependencies may be added as result of + execution and resource control parameters as documented in + systemd.exec5 + and + systemd.resource-control5. + + <filename>fstab</filename> @@ -130,7 +172,7 @@ When reading /etc/fstab a few special mount options are understood by systemd which influence how dependencies are created for mount points. systemd will create a - dependency of type or + dependency of type Wants= or (see option below), from either local-fs.target or remote-fs.target, depending whether the file diff --git a/man/systemd.path.xml b/man/systemd.path.xml index d02bc92ae6..1bd65ce86d 100644 --- a/man/systemd.path.xml +++ b/man/systemd.path.xml @@ -79,13 +79,24 @@ limitations as inotify, and for example cannot be used to monitor files or directories changed by other machines on remote NFS file systems. + - If a path unit is beneath another mount point in the file - system hierarchy, a dependency between both units is created - automatically. + + Automatic Dependencies + + If a path unit is beneath another mount unit in the file + system hierarchy, both a requirement and an ordering dependency + between both units are created automatically. + + An implicit Before= dependency is added + between a path unit and the unit it is supposed to activate. Unless DefaultDependencies=false is used, path units will implicitly have dependencies of type + Before= on paths.target, + dependencies of type After= and + Requires= on + sysinit.target, and have dependencies of type Conflicts= and Before= on shutdown.target. These ensure that path units are terminated cleanly prior to system shutdown. Only path units diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml index 164adb938a..0497f60546 100644 --- a/man/systemd.resource-control.xml +++ b/man/systemd.resource-control.xml @@ -89,6 +89,15 @@ use of resource control APIs from programs. + + Automatic Dependencies + + Units with the Slice= setting set get + automatic Requires= and + After= dependencies on the specified slice + unit. + + Options diff --git a/man/systemd.scope.xml b/man/systemd.scope.xml index fd65a851e2..f69b2ef635 100644 --- a/man/systemd.scope.xml +++ b/man/systemd.scope.xml @@ -72,6 +72,10 @@ url="http://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/">New Control Group Interfaces for an introduction on how to make use of scope units from programs. + + + + Automatic Dependencies Unless DefaultDependencies=false is used, scope units will implicitly have dependencies of @@ -82,6 +86,11 @@ shutdown. Only scope units involved with early boot or late system shutdown should disable this option. + + Additional implicit dependencies may be added as result of + resource control parameters as documented in + systemd.resource-control5. + diff --git a/man/systemd.service.xml b/man/systemd.service.xml index 4e5098f0e1..c6ed75d158 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -1,4 +1,4 @@ - + @@ -77,18 +77,6 @@ which configure resource control settings for the processes of the service. - Unless DefaultDependencies= is set to - , service units will implicitly have - dependencies of type Requires= and - After= on basic.target as - well as dependencies of type Conflicts= and - Before= on - shutdown.target. These ensure that normal - service units pull in basic system initialization, and are - terminated cleanly prior to system shutdown. Only services - involved with early boot or late system shutdown should disable - this option. - If a service is requested under a certain name but no unit configuration file is found, systemd looks for a SysV init script by the same name (with the .service suffix @@ -97,8 +85,39 @@ compatibility is quite comprehensive but not 100%. For details about the incompatibilities, see the Incompatibilities - with SysV document. - + with SysV document. + + + + Automatic Dependencies + + Services with Type=dbus set automatically + acquire dependencies of type Requires= and + After= on + dbus.socket. + + Socket activated service are automatically ordered after + their activated .socket units via an + automatic After= dependency. + + Unless DefaultDependencies= is set to + , service units will implicitly have + dependencies of type Requires= and + After= on sysinit.target, + a dependency of type After= on + basic.target as well as dependencies of + type Conflicts= and Before= + on shutdown.target. These ensure that normal + service units pull in basic system initialization, and are + terminated cleanly prior to system shutdown. Only services + involved with early boot or late system shutdown should disable + this option. + + Additional implicit dependencies may be added as result of + execution and resource control parameters as documented in + systemd.exec5 + and + systemd.resource-control5. diff --git a/man/systemd.slice.xml b/man/systemd.slice.xml index 87c2a3bce3..5c87bf0260 100644 --- a/man/systemd.slice.xml +++ b/man/systemd.slice.xml @@ -97,6 +97,14 @@ url="http://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/">New Control Group Interfaces for an introduction on how to make use of slice units from programs. + + + + Automatic Dependencies + + Slice units automatically gain dependencies of type + After= and Requires= on + their immediate parent slice unit. Unless DefaultDependencies=false is used, slice units will implicitly have dependencies of diff --git a/man/systemd.socket.xml b/man/systemd.socket.xml index 410886f841..beac053bf0 100644 --- a/man/systemd.socket.xml +++ b/man/systemd.socket.xml @@ -133,6 +133,40 @@ service file). + + Automatic Dependencies + + Socket units automatically gain a Before= + dependency on the service units they activate. + + Socket units referring to file system paths (such as AF_UNIX + sockets or FIFOs) implicitly gain Requires= and + After= dependencies on all mount units + necessary to access those paths. + + Socket units using the BindToDevice= + setting automatically gain a BindsTo= and + After= dependency on the device unit + encapsulating the specified network interface. + + If DefaultDependencies=yes is set (the + default), socket units automatically gain a + Before= dependency on + sockets.target. They also gain a pair of + After= and Requires= + dependency on sysinit.target, and a pair of + Before= and Conflicts= + dependencies on shutdown.target. These + dependencies ensure that the socket unit is started before normal + services at boot, and is stopped on shutdown. + + Additional implicit dependencies may be added as result of + execution and resource control parameters as documented in + systemd.exec5 + and + systemd.resource-control5. + + Options @@ -309,12 +343,14 @@ Specifies a network interface name to bind this socket to. If set, traffic will only be accepted from the specified network interfaces. This controls the - SO_BINDTODEVICE socket option (see - socket7 + SO_BINDTODEVICE socket option (see socket7 for details). If this option is used, an automatic dependency from this socket unit on the network interface device unit (systemd.device5 - is created. + is created. Note that setting this parameter might result in + additional dependencies to be added to the unit (see + above). @@ -719,7 +755,9 @@ with Accept=no. It defaults to the service that bears the same name as the socket (with the suffix replaced). In most cases, it should not be necessary to use - this option. + this option. Note that setting this parameter might result in + additional dependencies to be added to the unit (see + above). diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml index bc9ef826e1..c600405c87 100644 --- a/man/systemd.swap.xml +++ b/man/systemd.swap.xml @@ -68,14 +68,15 @@ Additional options are listed in systemd.exec5, - which define the execution environment the - swapon8 - binary is executed in, and in + which define the execution environment the swapon8 + binary is executed in, in systemd.kill5, - which define the way the processes are terminated, and in + which define the way the these processes are + terminated, and in systemd.resource-control5, - which configure resource control settings for the processes of the - service. + which configure resource control settings for these processes of the + unit. Swap units must be named after the devices or files they control. Example: the swap device @@ -84,15 +85,28 @@ the escaping logic used to convert a file system path to a unit name, see systemd.unit5. + - All swap units automatically get the appropriate - dependencies on the devices or on the mount points of the files + + Automatic Dependencies + + All swap units automatically get the + BindsTo= and After= + dependencies on the device units or the mount units of the files they are activated from. Swap units with DefaultDependencies= - enabled implicitly acquire a conflicting dependency to + enabled implicitly acquire a Conflicts= and an + After= dependency on umount.target so that they are deactivated at - shutdown. + shutdown, unless DefaultDependencies=no is + specified. + + Additional implicit dependencies may be added as result of + execution and resource control parameters as documented in + systemd.exec5 + and + systemd.resource-control5. diff --git a/man/systemd.target.xml b/man/systemd.target.xml index e790e9b77a..54a5f5035c 100644 --- a/man/systemd.target.xml +++ b/man/systemd.target.xml @@ -77,15 +77,20 @@ See systemd.special7 for details). + + + + Automatic Dependencies Unless DefaultDependencies= is set to - , target units will implicitly complement - all configured dependencies of type Wants=, + , target units will implicitly complement all + configured dependencies of type Wants=, Requires=, RequiresOverridable= with dependencies of type - After= if the units in question also have - DefaultDependencies=true. - + After=, unless an ordering dependency of any + kind between the target and the respective other unit is already + in place. Note that this behaviour is disabled if either unit has + DefaultDependencies=no. diff --git a/man/systemd.timer.xml b/man/systemd.timer.xml index c98258a0d7..8cf6c4683b 100644 --- a/man/systemd.timer.xml +++ b/man/systemd.timer.xml @@ -1,4 +1,4 @@ - + @@ -73,19 +73,29 @@ foo.timer activates a matching service foo.service. The unit to activate may be controlled by Unit= (see below). + + + + Automatic Dependencies + + Timer units automatically gain a Before= + dependency on the service they are supposed to activate. Unless DefaultDependencies= is set to , all timer units will implicitly have - dependencies of type Conflicts= and - Before= on shutdown.target - to ensure that they are stopped cleanly prior to system shutdown. - Timer units with at least one OnCalendar= - directive will have an additional After= - dependency on timer-sync.target to avoid - being started before the system clock has been correctly set. Only - timer units involved with early boot or late system shutdown - should disable the DefaultDependencies= - option. + dependencies of type Requires= and + After= on sysinit.target, + a dependency of type Before= on + timers.target, as well as + Conflicts= and Before= on + shutdown.target to ensure that they are + stopped cleanly prior to system shutdown. Timer units with at + least one OnCalendar= directive will have an + additional After= dependency on + timer-sync.target to avoid being started + before the system clock has been correctly set. Only timer units + involved with early boot or late system shutdown should disable + the DefaultDependencies= option. diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index caba7ea69d..b4044f43ef 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1,4 +1,4 @@ - + @@ -195,12 +195,6 @@ consider it mostly obsolete, and want people to use .d/ drop-ins instead. --> - Note that while systemd offers a flexible dependency system - between units it is recommended to use this functionality only - sparingly and instead rely on techniques such as bus-based or - socket-based activation which make dependencies implicit, - resulting in a both simpler and more flexible system. - Some unit names reflect paths existing in the file system namespace. Example: a device unit dev-sda.device refers to a device with the @@ -253,6 +247,31 @@ + + Automatic Dependencies + + Note that while systemd offers a flexible dependency system + between units it is recommended to use this functionality only + sparingly and instead rely on techniques such as bus-based or + socket-based activation which make dependencies implicit, + resulting in a both simpler and more flexible system. + + A number of unit dependencies are automatically established, + depending on unit configuration. On top of that, for units with + DefaultDependencies=yes (the default) a couple + of additional dependencies are added. The precise effect of + DefaultDependencies=yes depends on the unit + type (see below). + + If DefaultDependencies=yes is set, units + that are referenced by other units of type + .target via a Wants= or + Requires= dependency might automatically gain + an Before= dependency too. See + systemd.target5 + for details. + + Unit File Load Path