Skip to content

systemd

plantimager.commons.systemd Link

Various notifications for systemd.

see https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html#

is_systemd_process Link

is_systemd_process()

Returns True if the current process is running under systemd.

Source code in plantimager/commons/systemd.py
12
13
14
15
16
def is_systemd_process():
    """
    Returns True if the current process is running under systemd.
    """
    return os.environ.get("SYSTEMD_EXEC_PID") is not None or os.environ.get("NOTIFY_SOCKET") is not None

notify_ready Link

notify_ready()

Tells the service manager that service startup is finished, or the service finished re-loading its configuration.

This is only used by systemd if the service definition file has Type=notify or Type=notify-reload set.

Source code in plantimager/commons/systemd.py
18
19
20
21
22
23
def notify_ready():
    """Tells the service manager that service startup is finished, or the service finished re-loading its configuration.

    This is only used by systemd if the service definition file has Type=notify or Type=notify-reload set.
    """
    notifier.notify("READY=1")

notify_stopping Link

notify_stopping()

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.

Source code in plantimager/commons/systemd.py
35
36
37
38
39
40
41
def notify_stopping():
    """
    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.
    """
    notifier.notify("STOPPING=1")

notify_watchdog Link

notify_watchdog()

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 https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#WatchdogSec=

Source code in plantimager/commons/systemd.py
25
26
27
28
29
30
31
32
33
def notify_watchdog():
    """
    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 https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#WatchdogSec=
    """
    notifier.notify("WATCHDOG=1")