On 2026-07-09 a kernel keyring-GC oops left the player stuck in uninterruptible D-state while systemd, SSH, and the Flask app stayed alive -- so the box sat dead all night instead of recovering. A plain systemd/hardware watchdog only fires on a TOTAL hang and would not have caught that partial wedge. mediapi-watchdog.service (Type=simple, Restart=always, runs as root) pings mpv over its JSON IPC socket every 30s; after ~3 min of continuous failure it forces a reboot (systemctl reboot -ff, then SysRq as a kernel-level fallback that works even when userspace is wedged). A D-state mpv accepts the socket connect but never replies, so the ping times out and is caught. install.sh installs + enables it. Verified: no false positives while mpv is healthy; correctly detects a stopped mpv and reaches the reboot decision (tested in dry-run). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
15 lines
424 B
Text
15 lines
424 B
Text
[Unit]
|
|
Description=MediaPi watchdog -- reboots the Pi if the mpv player wedges
|
|
After=mediapi-mpv.service
|
|
Wants=mediapi-mpv.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
# Runs as root (no User=): must be able to force a reboot, including via SysRq,
|
|
# to recover a box whose player is wedged in uninterruptible D-state.
|
|
ExecStart=${PROJECT_DIR}/scripts/mediapi-watchdog.sh
|
|
Restart=always
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|