service: add 'debug' option to RestartMode=
authorLuca Boccassi <bluca@debian.org>
Fri, 26 Jul 2024 18:07:23 +0000 (19:07 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 27 Aug 2024 11:24:45 +0000 (12:24 +0100)
commit7d8bbfbe0852ec89590d1dc5e28afc95d6d44fa1
tree623499954eec628092582652c651080c1bbd30c2
parent23e3bddc482a1c83099b14830e23ded5bb7dfdcc
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.
13 files changed:
man/org.freedesktop.systemd1.xml
man/systemd.exec.xml
man/systemd.service.xml
src/core/dbus-unit.c
src/core/exec-invoke.c
src/core/execute-serialize.c
src/core/execute.c
src/core/execute.h
src/core/service.c
src/core/service.h
src/core/unit.c
src/core/unit.h
test/units/TEST-59-RELOADING-RESTART.sh