Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Systemd Daemon in Python with watchdog support

I want to write a daemon in python which gets started via systemd.

I wan to use Type=notify, this way I don't have to do the double fork magic.

According to the docs:

The reference implementation for this notification is provided by libsystemd-daemon.so

... how to do this with Python?

like image 622
guettli Avatar asked Apr 27 '16 15:04

guettli


1 Answers

Probably, you could use sdnotify python module which is a pure-python implementation of sd_notify protocol. Actually, the protocol is rather simple, so the module implementation is quite short.

To use watchdog machinery you should add WatchdocSec=<smth> to the unit file, and then send WATCHDOG=1 messages on a regular basis from your service. Check Restart= option as well.

like image 85
user3159253 Avatar answered Sep 21 '22 12:09

user3159253