Simple sd_notify(3) client functionality implemented in Python 3.
$ pip install sd-notify
import sd_notify
notify = sd_notify.Notifier()
if not notify.enabled():
# Then it's probably not running is systemd with watchdog enabled
raise Exception("Watchdog not enabled")
# Report a status message
notify.status("Initialising my service...")
time.sleep(3)
# Report that the program init is complete
notify.ready()
notify.status("Waiting for web requests...")
time.sleep(3)
# Report an error to the service manager
notify.notify_error("An irrecoverable error occured!")
# The service manager will probably kill the program here
time.sleep(3)
Send string msg
as bytes on the notification socket
Return a boolean stating whether watchdog is enabled
Report a healthy service state
Report a watchdog error. This program will likely be killed by the service manager.
If msg
is not None, it will be reported as an error message to the
service manager.
Report ready service state, i.e. completed initialisation
Set a service status message
[email protected] Dec 2019
See LICENSE file