streamd v0.2.2: session uptimes, egress DNS, Support, agent/Widevine
All checks were successful
release / build-and-upload (push) Successful in 7m2s

Dashboard Live uptimes + Recent runs from stream_sessions; overview.recent_sessions.
WireGuard netns resolv.conf + missing-deps WARN. Support donations card.
Agent start/stop/update, job_backoff default off, wvkey ensure/venv, phonecap retries,
modhost YAML enrich, DRM SetCredentials requires keys.
This commit is contained in:
404errordeveloper 2026-10-10 19:26:39 +02:00
parent 3ae1dd58b3
commit a091922efa
34 changed files with 2391 additions and 154 deletions

View file

@ -62,6 +62,7 @@ type streamProc struct {
nre *exec.Cmd
ffmpeg *exec.Cmd
started time.Time
sessionID int64 // stream_sessions row opened when NRE starts
workDir string
wwwDir string
tsPath string
@ -337,17 +338,19 @@ func (m *Media) Start(id int64) error {
}
m.Log.Info("downloader started", "stream", st.Name, "pid", nreCmd.Process.Pid)
sessionID, _ := m.Store.OpenSession(id)
sp := &streamProc{
id: id,
name: st.Name,
nre: nreCmd,
started: time.Now(),
workDir: workDir,
wwwDir: wwwDir,
tsPath: tsPath,
hlsIndex: filepath.Join(wwwDir, "index.m3u8"),
nreLog: nreLog,
mpdProxy: mpdProxy,
id: id,
name: st.Name,
nre: nreCmd,
started: time.Now(),
sessionID: sessionID,
workDir: workDir,
wwwDir: wwwDir,
tsPath: tsPath,
hlsIndex: filepath.Join(wwwDir, "index.m3u8"),
nreLog: nreLog,
mpdProxy: mpdProxy,
variantSpecs: variantSpecs,
outputSpecs: outputSpecs,
@ -438,6 +441,7 @@ func (m *Media) bootstrapHLS(sp *streamProc) {
StreamID: sp.id, Kind: db.EventCrashed, Severity: db.SevError,
Message: "downloader exited before any media arrived — see logs/" + sp.name + "-nre.log",
})
m.closeSession(sp, db.SessionNREExit, "down")
m.cleanupProc(sp.id)
return
}
@ -589,9 +593,11 @@ func (m *Media) Stop(id int64) error {
if st.Name != "" {
name = st.Name
}
_ = m.Store.CloseOpenSessions(id, db.SessionStopped, "stopped")
_ = m.Store.SetRuntime(id, db.RuntimePatch{Health: "stopped", PlayPath: "/hls/" + name + "/index.m3u8"})
return nil
}
m.closeSession(sp, db.SessionStopped, "stopped")
m.stopAllVariants(sp)
nrePID, ffPID := 0, 0
if sp.ffmpeg != nil && sp.ffmpeg.Process != nil {
@ -624,6 +630,15 @@ func (m *Media) Stop(id int64) error {
return nil
}
// closeSession ends the open stream_sessions row for this process, if any.
func (m *Media) closeSession(sp *streamProc, reason, health string) {
if sp == nil || sp.sessionID == 0 {
return
}
_ = m.Store.CloseSession(sp.sessionID, reason, health)
sp.sessionID = 0
}
func (m *Media) Restart(id int64) error {
m.Log.Info("hard restart", "stream_id", id)
_ = m.Stop(id)
@ -702,6 +717,7 @@ func (m *Media) refreshHealth(id int64) {
Message: fmt.Sprintf("downloader exited after %.0fs — see logs/%s-nre.log", uptime, sp.name),
})
m.Log.Error("downloader exited", "stream", sp.name, "uptime_s", int(uptime))
m.closeSession(sp, db.SessionNREExit, "down")
m.report(sp, "down")
m.cleanupProc(id)
return