systemd management: replace Requires=network with After=

Following the upstream documentation for systemd network target:
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

It is not supposed to be used as an active unit and it cannot be started
directly. Quote from the website:

Note that network.target is a passive unit: you cannot start it directly
and it is not pulled in by any services that want to make use of the
network. Instead, it is pulled in by the network management service
itself. Services using the network should hence simply place an
After=network.target dependency in their unit files, and avoid any
Wants=network.target or even Requires=network.target.

This patch changes the documentation to follow the upstream
recommendation.
This commit is contained in:
Martin Sehnoutka 2021-09-24 11:06:52 +02:00
parent 3f52d2fc67
commit 34fc23c4f1
2 changed files with 5 additions and 5 deletions

View file

@ -33,7 +33,7 @@ If you enable the custom _systemd_ service to start at boot (`systemctl enable f
----
[Unit]
Description=My custom service
Requires=network.target
After=network.target
----
. Identify the command used to start the service in the SysVinit script and convert this to the _systemd_ equivalent. For example, the script might contain a `start` function in the following format:

View file

@ -25,15 +25,15 @@ This procedure creates a basic configuration file to control the `foo` service.
+
`Description`::
A string describing the unit. _Systemd_ displays this description next to the unit name in the user interface.
`Requires`::
Defines unit to use as a dependency for the service. If you activate the unit, _systemd_ activates the units listed in `Requires` as well. For example, the `foo` service might require network connectivity, which means the `foo` services requires `network.target` as a dependency.
`After`::
Defines a relationship with a second unit. If you activate the unit, _systemd_ activates it only after the second one. For example, the `foo` service might require network connectivity, which means the `foo` services specifies `network.target` as an `After=` condition.
+
The resulting `[Unit]` section looks like this:
+
----
[Unit]
Description=My custom service
Requires=network.target
After=network.target
----
.. The `[Service]` section provides instructions on how to control the service. The `foo` service uses the following parameters:
@ -61,7 +61,7 @@ ExecStart=/usr/bin/sleep infinity
----
[Unit]
Description=My custom service
Requires=network.target
After=network.target
[Service]
Type=simple