﻿# Keep a service watchdog tied to useful progress

Connect watchdog pings to a defined service-liveness signal that distinguishes a stuck useful path from ordinary idle or long work.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-linux-systemd-watchdog/
Language: en

A model service sends watchdog pings from a timer thread even while its inference queue is deadlocked. The manager sees a responsive notification sender, not necessarily useful service progress. Define what the watchdog is meant to detect before choosing the code path that keeps the service alive.

## Read the enabled contract

Inspect WatchdogSec and the service's supported notification behavior. The service can use the documented helper to detect whether pings are expected and the relevant interval. Watchdog activation follows startup completion, so it is different from the startup timeout. Preserve the installed configuration and lifecycle state rather than assuming an environment variable always means the current process owns notifications.

## Choose a meaningful progress signal

Tie liveness to an application condition that can distinguish a stuck execution path from legitimate idle time. A timer that runs independently of the failed path may keep reporting health indefinitely. Conversely, requiring completed requests when no requests arrive would classify normal idleness as failure. State the intended progress or responsiveness observation and its permitted age.

## Respect legitimate long operations

Weight loading, long generation and blocked external work have different lifetimes. A watchdog interval should not silently become a universal request deadline. Keep startup monitoring, request cancellation and service liveness as distinct policies. Measure scheduling delays and expected progress cadence so a healthy but busy worker is not repeatedly terminated by an unsuitable heartbeat design.

## Verify sender ownership

Inspect NotifyAccess, the sending process and notification results. A wrapper or child can inherit watchdog-related environment while not being the intended owner. The helper's documented environment handling can prevent inappropriate inheritance. Multiple independent ping sources complicate diagnosis, because a healthy auxiliary path may conceal failure of the main one the policy was supposed to protect.

## Test a stalled useful path

Use an isolated synthetic service to compare normal idle, useful work and a deliberately stalled critical path. Confirm the expected timeout, termination and configured restart behavior without production requests. Acceptance means the selected signal detects the intended loss of progress. It does not guarantee correct outputs, identify the deadlock's cause or make repeated restarts a substitute for fixing it.

## Primary references

[systemd Service Configuration](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html).

[Watchdog Notification Detection](https://raw.githubusercontent.com/systemd/systemd/main/man/sd_watchdog_enabled.xml).

[Service Manager Notification API](https://raw.githubusercontent.com/systemd/systemd/main/man/sd_notify.xml).

Related reading: [Request deadlines: budgeting queueing, prefill and streaming](/journal/provider-request-deadline-stage-budget/); [Golden inference API fixtures: test the contract rather than prose](/journal/provider-golden-contract-fixtures/).
