module

AptLarder::SystemD

Thin wrapper around the systemd sd_notify(3) protocol.

Sends newline-delimited state strings to the socket named by $NOTIFY_SOCKET. All methods are no-ops when the variable is unset (i.e. when not managed by systemd).

A single UNIXSocket is opened on first use and reused for all subsequent notifications, avoiding repeated open/close syscalls on the watchdog keepalive path.

Service file

[Service]
Type=notify
NotifyAccess=main
WatchdogSec=30
ExecStart=/usr/bin/apt-larder server --config /etc/apt-larder.yml

Constants

Log = ::Log.for("apt-larder.systemd")

Class methods

ready

Sends READY=1 — signals that the service is fully started and accepting connections.

Source
reset_socket

Closes and discards the persistent socket. Intended for tests only.

Source
start_watchdog

Spawns a fiber that sends WATCHDOG=1 at half the watchdog interval. Does nothing when the watchdog is not configured.

Source
status(message : String) : Nil

Sends STATUS=<message> — a human-readable status line shown by systemctl status.

Source
stopping

Sends STOPPING=1 — signals that the service has received a shutdown request and is draining in-flight requests.

Source
watchdog

Sends WATCHDOG=1 — resets the watchdog timer. Call at most every watchdog_usec / 2 microseconds.

Source
watchdog_interval

Returns the watchdog interval from $WATCHDOG_USEC, or nil if the watchdog is not configured.

Source