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:
@@ -212,14 +212,17 @@ func (p *Player) Command(args ...any) (map[string]any, error) {
|
||||
return nil, fmt.Errorf("no reply from mpv ipc")
|
||||
}
|
||||
|
||||
// Healthy probes mpv over IPC and reports whether it is actively playing (has
|
||||
// a finite time position advancing). A false result signals the daemon to
|
||||
// consider restarting the slot even if the process is still alive (frozen).
|
||||
// Healthy probes mpv over IPC and reports whether it is responsive. It queries
|
||||
// a property that always exists (mpv-version) rather than time-pos, because a
|
||||
// live stream with caching disabled can legitimately report time-pos as
|
||||
// unavailable while playing fine — using it here caused false "unhealthy"
|
||||
// verdicts and needless restarts. A false result now means mpv's IPC didn't
|
||||
// answer at all, i.e. the process is genuinely hung.
|
||||
func (p *Player) Healthy() bool {
|
||||
if !p.Running() {
|
||||
return false
|
||||
}
|
||||
reply, err := p.Command("get_property", "time-pos")
|
||||
reply, err := p.Command("get_property", "mpv-version")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user