Documentation
¶
Overview ¶
Package sdnotify implements the small subset of the systemd sd_notify(3) protocol the daemon needs (READY=1, STOPPING=1, WATCHDOG=1) without pulling in a dependency on go-systemd.
On non-Linux platforms every function is a no-op (see sdnotify_other.go). On Linux the functions look at $NOTIFY_SOCKET; when it's empty (i.e. we're not under systemd) every call is also a no-op. This means callers can wire the hooks unconditionally — no branching on OS or service-manager presence required.
Function-level docs live with the build-tag-specific declarations in sdnotify_linux.go and sdnotify_other.go so `go doc` picks them up on the matching platform.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WatchdogLoop ¶
WatchdogLoop kicks WATCHDOG=1 at half the interval declared by WATCHDOG_USEC. Returns when ctx is cancelled, when WATCHDOG_USEC is unset/unparseable, when NOTIFY_SOCKET is unset (in which case every kick would no-op anyway and the spinning goroutine has no purpose), or when WATCHDOG_PID is set and doesn't match the current PID.
systemd uses WATCHDOG_PID to scope the watchdog to a specific process in a multi-process service (e.g. a supervisor that forks workers). Without the PID check, a child process that inherits the env vars would also try to kick the watchdog, which is at best wasted IPC and at worst masks a stalled main process.
The half-interval pacing matches the systemd manual recommendation.
Types ¶
This section is empty.