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

@ -437,6 +437,15 @@ func (r *HLSSessionRegistry) HasLiveEncode() bool {
return false
}
// Count reports how many sessions are currently registered (live or recently
// finished but not yet swept). Used by the graceful auto-upgrade gate to defer
// applying an update while the agent is actively streaming.
func (r *HLSSessionRegistry) Count() int {
r.mu.RLock()
defer r.mu.RUnlock()
return len(r.sessions)
}
// Remove drops a session from the registry without closing it.
func (r *HLSSessionRegistry) Remove(id string) {
r.mu.Lock()