From 7d8bbfbe0852ec89590d1dc5e28afc95d6d44fa1 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 26 Jul 2024 19:07:23 +0100 Subject: service: add 'debug' option to RestartMode= One of the major pait points of managing fleets of headless nodes is that when something fails at startup, unless debug level was already enabled (which usually isn't, as it's a firehose), one needs to manually enable it and pray the issue can be reproduced, which often is really hard and time consuming, just to get extra info. Usually the extra log messages are enough to triage an issue. This new option makes it so that when a service fails and is restarted due to Restart=, log level for that unit is set to debug, so that all setup code in pid1 and sd-executor logs at debug level, and also a new DEBUG_INVOCATION=1 env var is passed to the service itself, so that it knows it should start with a higher log level. Once the unit succeeds or reaches the rate limit the original level is restored. --- man/systemd.service.xml | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'man/systemd.service.xml') diff --git a/man/systemd.service.xml b/man/systemd.service.xml index d3ed79effb..047fb912e9 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -936,20 +936,40 @@ Takes a string value that specifies how a service should restart: - If set to (the default), the service restarts by - going through a failed/inactive state. - - If set to , the service transitions to the activating - state directly during auto-restart, skipping failed/inactive state. - ExecStopPost= is invoked. - OnSuccess= and OnFailure= are skipped. + + If set to (the default), the service restarts by going through + a failed/inactive state. + + + + + + If set to , the service transitions to the activating + state directly during auto-restart, skipping failed/inactive state. + ExecStopPost= is invoked. + OnSuccess= and OnFailure= are skipped. + + This option is useful in cases where a dependency can fail temporarily but we don't + want these temporary failures to make the dependent units fail. Dependent units are not + notified of these temporary failures. + + + + + + If set to , the service manager will log messages that are + related to this unit at debug level while automated restarts are attempted, until either the + service hits the rate limit or it succeeds, and the $DEBUG_INVOCATION=1 + environment variable will be set for the unit. This is useful to be able to get additional + information when a service fails to start, without needing to proactively or permanently + enable debug level logging in systemd, which is very verbose. This is otherwise equivalent + to mode. + + + - This option is useful in cases where a dependency can fail temporarily - but we don't want these temporary failures to make the dependent units fail. - When this option is set to , dependent units are not notified of these temporary failures. - -- cgit v1.2.3