Harden health probe against false restarts

Probe mpv-version (always present) instead of time-pos, which live
streams with caching off can report unavailable while playing fine —
that produced false unhealthy verdicts. Also require 3 consecutive
misses (~60s) before force-restarting a hung stream.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Woodard
2026-07-01 19:41:48 -05:00
parent 0fb731a71e
commit eb05c48db8
2 changed files with 11 additions and 6 deletions

View File

@@ -232,8 +232,10 @@ func (d *Daemon) healthLoop(ctx context.Context) {
continue
}
stalls[p.Slot]++
if stalls[p.Slot] >= 2 {
d.log.Warn("stream stalled, forcing restart", "slot", p.Slot, "camera", p.Name)
// Require three consecutive unresponsive probes (~60s) before
// forcing a restart, so a brief IPC hiccup never bounces a stream.
if stalls[p.Slot] >= 3 {
d.log.Warn("stream hung, forcing restart", "slot", p.Slot, "camera", p.Name, "misses", stalls[p.Slot])
p.Stop() // Supervise relaunches
stalls[p.Slot] = 0
}