Sovite.Systemd.Watchdog (sovite v0.6.0)

Copy Markdown View Source

Sends the systemd watchdog ping (WATCHDOG=1) every half watchdog interval, for units with WatchdogSec=.

children = [
  {Sovite.Systemd.Watchdog, check: &MyApp.healthy?/0}
]

The first ping is sent at start. When the watchdog is disabled (see Sovite.Systemd.watchdog_interval/1), as outside systemd, start_link/1 returns :ignore and no process runs.

A :check function makes the ping depend on the service's health: when it returns anything but true, or raises, that tick's ping is skipped, and systemd restarts the service once a whole interval passes without one. It runs in the watchdog process, so a check that hangs stops the pings too.

Options

  • :check - a 0-arity function returning true when the service is healthy. Defaults to none: every tick pings.
  • :env - a map of environment variables to read instead of the OS environment, as in Sovite.Systemd.
  • :name - registered name of the process.

Telemetry

  • [:sovite, :systemd, :watchdog, :skipped] - %{}, %{reason}: the check failed, so no ping was sent. reason is what the check returned, or {kind, reason} when it raised, threw, or exited.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the watchdog, or returns :ignore when it is disabled.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the watchdog, or returns :ignore when it is disabled.