[systemd-devel] what is sd_notify() really for ?
Reindl Harald
h.reindl at thelounge.net
Mon Apr 17 06:37:01 UTC 2017
Am 17.04.2017 um 00:47 schrieb Enrico Weigelt, metux IT consult:
> On 17.04.2017 00:04, Lennart Poettering wrote:
>
>> Please always check the man pages if you have questions regarding a
>> specific systemd interface:
>>
>> https://www.freedesktop.org/software/systemd/man/sd_notify.html
>
> Done so, of course. Unfortunately, it doesn't answer my questions,
> eg. what the service manager actually does w/ that information.
really?
what exactly do you not understand in the descriptions below?
if there are several services depending on each other you don't want to
start depending services while your big database still inits and is not
ready for connections - for "Restart=always" it maybe not enough that
your proess is just running - hence the watchdog where the service needs
to say "i am still alive"
READY=1
Tells the service manager that service startup is finished. This is
only used by systemd if the service definition file has Type=notify set.
Since there is little value in signaling non-readiness, the only value
services should send is "READY=1" (i.e. "READY=0" is not defined).
Example 2. Extended Start-up Notification
A service could send the following after completing initialization:
sd_notifyf(0, "READY=1\n"
"STATUS=Processing requests?\n"
"MAINPID=%lu",
(unsigned long) getpid());
RELOADING=1
Tells the service manager that the service is reloading its
configuration. This is useful to allow the service manager to track the
service's internal state, and present it to the user. Note that a
service that sends this notification must also send a "READY=1"
notification when it completed reloading its configuration.
STOPPING=1
Tells the service manager that the service is beginning its
shutdown. This is useful to allow the service manager to track the
service's internal state, and present it to the user.
WATCHDOG=1
Tells the service manager to update the watchdog timestamp. This is
the keep-alive ping that services need to issue in regular intervals if
WatchdogSec= is enabled for it. See systemd.service(5) for information
how to enable this functionality and sd_watchdog_enabled(3) for the
details of how the service can check whether the watchdog is enabled.
https://www.freedesktop.org/software/systemd/man/sd_watchdog_enabled.html
More information about the systemd-devel
mailing list