diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index 149228ee02..6c15d2d837 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -83,6 +83,16 @@
COMMAND may be omitted. In this case, systemd-run creates only a
.path, .socket, or .timer unit that triggers the
specified unit.
+
+ By default, services created with systemd-run default to the type,
+ see the description of Type= in
+ systemd.service5 for
+ details. Note that when this type is used the service manager (and thus the systemd-run command)
+ considers service start-up successful as soon as the fork() for the main service process
+ succeeded, i.e. before the execve() is invoked, and thus even if the specified command cannot
+ be started. Consider using the service type (i.e. ) to
+ ensure that systemd-run returns successfully only if the specified command line has been
+ successfully started.
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index f14a057280..0cd5385f9b 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -153,77 +153,93 @@
Type=
- Configures the process start-up type for this
- service unit. One of
- ,
- ,
- ,
- ,
- or
- .
+
+ Configures the process start-up type for this service unit. One of ,
+ , , , ,
+ or :
- If set to (the default if
- neither Type= nor
- BusName=, but ExecStart=
- are specified), it is expected that the process configured
- with ExecStart= is the main process of the
- service. In this mode, if the process offers functionality to
- other processes on the system, its communication channels
- should be installed before the daemon is started up (e.g.
- sockets set up by systemd, via socket activation), as systemd
- will immediately proceed starting follow-up units.
+
+ If set to (the default if ExecStart= is
+ specified but neither Type= nor BusName= are), the service manager
+ will consider the unit started immediately after the main service process has been forked off. It is
+ expected that the process configured with ExecStart= is the main process of the
+ service. In this mode, if the process offers functionality to other processes on the system, its
+ communication channels should be installed before the service is started up (e.g. sockets set up by
+ systemd, via socket activation), as the service manager will immediately proceed starting follow-up units,
+ right after creating the main service process, and before executing the service's binary. Note that this
+ means systemctl start command lines for services will report
+ success even if the service's binary cannot be invoked successfully (for example because the selected
+ User= doesn't exist, or the service binary is missing).
- If set to , it is expected that
- the process configured with ExecStart= will
- call fork() as part of its start-up. The
- parent process is expected to exit when start-up is complete
- and all communication channels are set up. The child continues
- to run as the main daemon process. This is the behavior of
- traditional UNIX daemons. If this setting is used, it is
- recommended to also use the PIDFile=
- option, so that systemd can identify the main process of the
- daemon. systemd will proceed with starting follow-up units as
- soon as the parent process exits.
+ The type is similar to , but the service
+ manager will consider the unit started immediately after the main service binary has been executed. The service
+ manager will delay starting of follow-up units until that point. (Or in other words:
+ proceeds with further jobs right after fork() returns, while
+ will not proceed before both fork() and
+ execve() in the service process succeeded.) Note that this means systemctl
+ start command lines for services will report failure when the service's
+ binary cannot be invoked successfully (for example because the selected User= doesn't
+ exist, or the service binary is missing).
- Behavior of is similar to
- ; however, it is expected that the
- process has to exit before systemd starts follow-up units.
- RemainAfterExit= is particularly useful for
- this type of service. This is the implied default if neither
- Type= nor ExecStart= are
- specified.
+ If set to , it is expected that the process configured with
+ ExecStart= will call fork() as part of its start-up. The parent
+ process is expected to exit when start-up is complete and all communication channels are set up. The child
+ continues to run as the main service process, and the service manager will consider the unit started when
+ the parent process exits. This is the behavior of traditional UNIX services. If this setting is used, it is
+ recommended to also use the PIDFile= option, so that systemd can reliably identify the
+ main process of the service. systemd will proceed with starting follow-up units as soon as the parent
+ process exits.
- Behavior of is similar to
- ; however, it is expected that the
- daemon acquires a name on the D-Bus bus, as configured by
- BusName=. systemd will proceed with
- starting follow-up units after the D-Bus bus name has been
- acquired. Service units with this option configured implicitly
- gain dependencies on the dbus.socket
- unit. This type is the default if BusName=
- is specified.
+ Behavior of is similar to ; however, the
+ service manager will consider the unit started after the main process exits. It will then start follow-up
+ units. RemainAfterExit= is particularly useful for this type of
+ service. Type= is the implied default if neither
+ Type= nor ExecStart= are specified.
- Behavior of is similar to
- ; however, it is expected that the
- daemon sends a notification message via
- sd_notify3
- or an equivalent call when it has finished starting up.
- systemd will proceed with starting follow-up units after this
- notification message has been sent. If this option is used,
- NotifyAccess= (see below) should be set to
- open access to the notification socket provided by systemd. If
- NotifyAccess= is missing or set to
- , it will be forcibly set to
- . Note that currently
- Type= will not work
- if used in combination with
- PrivateNetwork=.
+ Behavior of is similar to ; however, it is
+ expected that the service acquires a name on the D-Bus bus, as configured by
+ BusName=. systemd will proceed with starting follow-up units after the D-Bus bus name
+ has been acquired. Service units with this option configured implicitly gain dependencies on the
+ dbus.socket unit. This type is the default if BusName= is
+ specified.
- Behavior of is very similar to ; however, actual execution
- of the service program is delayed until all active jobs are dispatched. This may be used to avoid interleaving
- of output of shell services with the status output on the console. Note that this type is useful only to
- improve console output, it is not useful as a general unit ordering tool, and the effect of this service type
- is subject to a 5s time-out, after which the service program is invoked anyway.
+ Behavior of is similar to ; however, it is
+ expected that the service sends a notification message via
+ sd_notify3 or an
+ equivalent call when it has finished starting up. systemd will proceed with starting follow-up units after
+ this notification message has been sent. If this option is used, NotifyAccess= (see
+ below) should be set to open access to the notification socket provided by systemd. If
+ NotifyAccess= is missing or set to , it will be forcibly set to
+ . Note that currently Type= will not work if
+ used in combination with PrivateNetwork=.
+
+ Behavior of is very similar to ; however,
+ actual execution of the service program is delayed until all active jobs are dispatched. This may be used
+ to avoid interleaving of output of shell services with the status output on the console. Note that this
+ type is useful only to improve console output, it is not useful as a general unit ordering tool, and the
+ effect of this service type is subject to a 5s time-out, after which the service program is invoked
+ anyway.
+
+
+ It is generally recommended to use Type= for long-running
+ services whenever possible, as it is the simplest and fastest option. However, as this service type won't
+ propagate service start-up failures and doesn't allow ordering of other units against completion of
+ initialization of the service (which for example is useful if clients need to connect to the service through
+ some form of IPC, and the IPC channel is only established by the service itself — in contrast to doing this
+ ahead of time through socket or bus activation or similar), it might not be sufficient for many cases. If so,
+ or (the latter only in case the service provides a D-Bus
+ interface) are the preferred options as they allow service program code to precisely schedule when to
+ consider the service started up successfully and when to proceed with follow-up units. The
+ service type requires explicit support in the service codebase (as
+ sd_notify() or an equivalent API needs to be invoked by the service at the appropriate
+ time) — if it's not supported, then is an alternative: it supports the traditional
+ UNIX service start-up protocol. Finally, might be an option for cases where it is
+ enough to ensure the service binary is invoked, and where the service binary itself executes no or little
+ initialization on its own (and its initialization is unlikely to fail). Note that using any type other than
+ possibly delays the boot process, as the service manager needs to wait for service
+ initialization to complete. It is hence recommended not to needlessly use any types other than
+ . (Also note it is generally not recommended to use or
+ for long-running services.)