feat(agent): el auto-update difiere hasta que no haya stream activo

Un auto-update reiniciaba el daemon al momento y cortaba la
reproducción en curso (mata la sesión HLS viva → freeze → F5). Ahora
el path AUTO (OnUpgrade) difiere indefinido mientras haya streams
activos y aplica solo en idle. Ningún update en segundo plano vale
cortar un visionado.

- HLSSessionRegistry.Count() + playerSessionRegistry.count() →
  GetActiveStreamCount() = player (HLS/direct/remux) + transcode HLS.
- deferAutoUpgradeUntilIdle: guard de un solo waiter, ticker 30s,
  aplica al llegar a 0 streams.
- `unarr update` (manual) SIN cambios: aplica al momento = escape
  hatch para un fix urgente.
- SyncRequest.agentStatus ("updating") reportado antes del restart
  para que la web pueda avisar en vez de dar error de sesión.
This commit is contained in:
Deivid Soto 2026-06-12 09:46:23 +02:00
parent 91ee5e4b6f
commit 59da949a53
6 changed files with 84 additions and 1 deletions

View file

@ -41,6 +41,12 @@ func (r *playerSessionRegistryT) remove(sessionID string) {
delete(r.cancels, sessionID)
}
func (r *playerSessionRegistryT) count() int {
r.mu.Lock()
defer r.mu.Unlock()
return len(r.cancels)
}
// cancelAllPlayerSessions cancels every running session. Called on daemon
// shutdown so the ffmpeg children and SSE consumers exit cleanly.
func cancelAllPlayerSessions() {