core: let user define start-/stop-timeout behaviour
The usual behaviour when a timeout expires is to terminate/kill the service. This is what user usually want in production systems. To debug services that fail to start/stop (especially sporadic failures) it might be necessary to trigger the watchdog machinery and write core dumps, though. Likewise, it is usually just a waste of time to gracefully stop a stuck service. Instead it might save time to go directly into kill mode. This commit adds two new options to services: TimeoutStartFailureMode= and TimeoutStopFailureMode=. Both take the same values and tweak the behavior of systemd when a start/stop timeout expires: * 'terminate': is the default behaviour as it has always been, * 'abort': triggers the watchdog machinery and will send SIGABRT (unless WatchdogSignal was changed) and * 'kill' will directly send SIGKILL. To handle the stop failure mode in stop-post state too a new final-watchdog state needs to be introduced.
This commit is contained in:
committed by
Lennart Poettering
parent
8b5616fa91
commit
bf76080180
+30
-11
@@ -560,16 +560,12 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>TimeoutStartSec=</varname></term>
|
||||
<listitem><para>Configures the time to wait for start-up. If a
|
||||
daemon service does not signal start-up completion within the
|
||||
configured time, the service will be considered failed and
|
||||
will be shut down again. Takes a unit-less value in seconds,
|
||||
or a time span value such as "5min 20s". Pass
|
||||
<literal>infinity</literal> to disable the timeout logic. Defaults to
|
||||
<varname>DefaultTimeoutStartSec=</varname> from the manager
|
||||
configuration file, except when
|
||||
<varname>Type=oneshot</varname> is used, in which case the
|
||||
timeout is disabled by default (see
|
||||
<listitem><para>Configures the time to wait for start-up. If a daemon service does not signal start-up
|
||||
completion within the configured time, the service will be considered failed and will be shut down again. The
|
||||
precise action depends on the <varname>TimeoutStartFailureMode=</varname> option. Takes a unit-less value in
|
||||
seconds, or a time span value such as "5min 20s". Pass <literal>infinity</literal> to disable the timeout logic.
|
||||
Defaults to <varname>DefaultTimeoutStartSec=</varname> from the manager configuration file, except when
|
||||
<varname>Type=oneshot</varname> is used, in which case the timeout is disabled by default (see
|
||||
<citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
|
||||
</para>
|
||||
|
||||
@@ -588,7 +584,8 @@
|
||||
<listitem><para>This option serves two purposes. First, it configures the time to wait for each
|
||||
<varname>ExecStop=</varname> command. If any of them times out, subsequent <varname>ExecStop=</varname> commands
|
||||
are skipped and the service will be terminated by <constant>SIGTERM</constant>. If no <varname>ExecStop=</varname>
|
||||
commands are specified, the service gets the <constant>SIGTERM</constant> immediately. Second, it configures the time
|
||||
commands are specified, the service gets the <constant>SIGTERM</constant> immediately. This default behavior
|
||||
can be changed by the <varname>TimeoutStopFailureMode=</varname> option. Second, it configures the time
|
||||
to wait for the service itself to stop. If it doesn't terminate in the specified time, it will be forcibly terminated
|
||||
by <constant>SIGKILL</constant> (see <varname>KillMode=</varname> in
|
||||
<citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
|
||||
@@ -646,6 +643,28 @@
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>TimeoutStartFailureMode=</varname></term>
|
||||
<term><varname>TimeoutStopFailureMode=</varname></term>
|
||||
|
||||
<listitem><para>These options configure the action that is taken in case a daemon service does not signal
|
||||
start-up within its configured <varname>TimeoutStartSec=</varname>, respectively if it does not stop within
|
||||
<varname>TimeoutStopSec=</varname>. Takes one of <option>terminate</option>, <option>abort</option> and
|
||||
<option>kill</option>. Both options default to <option>terminate</option>.</para>
|
||||
|
||||
<para>If <option>terminate</option> is set the service will be gracefully terminated by sending the signal
|
||||
specified in <varname>KillSignal=</varname> (defaults to <constant>SIGTERM</constant>, see
|
||||
<citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). If the
|
||||
service does not terminate the <varname>FinalKillSignal=</varname> is sent after
|
||||
<varname>TimeoutStopSec=</varname>. If <option>abort</option> is set, <varname>WatchdogSignal=</varname> is sent
|
||||
instead and <varname>TimeoutAbortSec=</varname> applies before sending <varname>FinalKillSignal=</varname>.
|
||||
This setting may be used to analyze services that fail to start-up or shut-down intermittently.
|
||||
By using <option>kill</option> the service is immediately terminated by sending
|
||||
<varname>FinalKillSignal=</varname> without any further timeout. This setting can be used to expedite the
|
||||
shutdown of failing services.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>RuntimeMaxSec=</varname></term>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user