[systemd-devel] what is sd_notify() really for ?
Hi folks, I just wonder what sd_notify()+friends is really for. What does the service manager actually do with that information? Is this just informational or does it do certain decisions (eg. starting/stopping other depending services, etc) on that ? Is this somehow related to systems monitoring (like eg.nagios does) ? What is the meaning of the optional PID here ? Can one process send notifications on behalf of another ? A few examples of real world usecases would be very helpful. thx. --mtx ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] what is sd_notify() really for ?
On Sun, 16.04.17 23:48, Enrico Weigelt, metux IT consult (enrico.weig...@gr13.net) wrote: > Hi folks, > > > I just wonder what sd_notify()+friends is really for. What does the > service manager actually do with that information? > > Is this just informational or does it do certain decisions (eg. > starting/stopping other depending services, etc) on that ? > > Is this somehow related to systems monitoring (like eg.nagios does) ? > > What is the meaning of the optional PID here ? Can one process send > notifications on behalf of another ? > > A few examples of real world usecases would be very helpful. 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 It provides an overview of the various messages, and comes with examples. It should answer all your questions. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] what is sd_notify() really for ?
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. --mtx ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] what is sd_notify() really for ?
On Mon, 17.04.17 00:47, Enrico Weigelt, metux IT consult (enrico.weig...@gr13.net) wrote: > 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. Well, it's used for a variety of things. I figure most relevant usage is for the implementation of Type=notify services, which is referenced from the man page, if you have a look. For details about that option see: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type= Another major use is for the watchdog logic, i.e. the implementation of the WatchdogSec= setting, also referenced from sd_notify()'s man page. For details about this specific setting see: https://www.freedesktop.org/software/systemd/man/systemd.service.html#WatchdogSec= And there's more. For example, you can use it to store fds in the service manager, so that your service may be restarted (or terminated abnormally) and access to specific sockets, devices, or any other object that may be referenced with a file descriptor isn't lost. If the brief descriptions in the man pages aren't sufficient, I'd recommend you to have a look at the sources. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] what is sd_notify() really for ?
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 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel