[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to make systemd execute init.d script status statements?



Looks like systemd does not execute the statements in status) case of the init script at all, but just checks if the daemon process exists. My '/etc/init.d/<my own daemon> status' did much more, i.e., it checked if the daemon was actually able to do some real work.

So far I have had no luck in finding the answer from the web.

You will find the answer here:

* http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/unix-daemon-readiness-protocol-problems.html
* https://freedesktop.org/software/systemd/man/sd_notify.html
* https://freedesktop.org/software/systemd/man/systemd-notify.html
* https://lists.freedesktop.org/archives/systemd-devel/2014-April/018797.html

If you want to make your daemon interoperate with systemd's status mechanism to the extent of having custom status reports, you have to modify your daemon to send readiness notification messages through a socket to the systemd service manager. That way, not only will "/etc/init.d/jh status" report your custom statuses, so too will "systemctl status jh" and (possibly) so too will (some) GUI administration tools.

To do this, you must write a service unit for your service. Sticking with a van Smoorenbug rc script and relying upon the systemd-sysv-generator to write a compatibility service unit on the fly to encapsulate it won't work, for several reasons. For starters, the generator doesn't generate Type=notify service units and uses RemainAfterExit=true (which prevents detection of service abends).


Reply to: