streamd: serve start/stop/update, streamd.yaml, egress, module panel fixes
- Add streamd serve start|stop|restart|status|update with auto-written streamd.yaml - Panel modules: STREAMD_MODULES_DIR for describe, YAML channel fallback, textarea value fix - Per-stream WireGuard/SOCKS egress profiles + Settings UI - Drop drm-* from release builds; track streamd-bg.sh / streamd-update.sh wrappers - Docs: streamd-server-setup lifecycle and update flow
This commit is contained in:
parent
da8e1123ec
commit
8fc7e4c0b8
57 changed files with 4031 additions and 257 deletions
|
|
@ -2,8 +2,12 @@ package api
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"streamd/apps/streamd/internal/auth"
|
||||
"streamd/apps/streamd/internal/modstore"
|
||||
"streamd/modhost"
|
||||
"streamd/mpd"
|
||||
"streamd/repo"
|
||||
|
|
@ -44,13 +48,17 @@ func (h *Handler) apps(w http.ResponseWriter, r *http.Request) {
|
|||
for _, m := range mods {
|
||||
bin, err := modhost.EnsureBuilt(m)
|
||||
if err != nil {
|
||||
out = append(out, appInfo{Name: m.Name, Channels: []channelInfo{}, Rewriter: "none", Error: err.Error()})
|
||||
info := appInfo{Name: m.Name, Channels: []channelInfo{}, Rewriter: "none", Error: err.Error()}
|
||||
h.fillChannelsFromStore(&info, m.Name)
|
||||
out = append(out, info)
|
||||
h.logger().Warn("module describe skipped", "module", m.Name, "err", err)
|
||||
continue
|
||||
}
|
||||
d, err := modhost.RunDescribe(bin)
|
||||
if err != nil {
|
||||
out = append(out, appInfo{Name: m.Name, Channels: []channelInfo{}, Rewriter: "none", Error: err.Error()})
|
||||
info := appInfo{Name: m.Name, Channels: []channelInfo{}, Rewriter: "none", Error: err.Error()}
|
||||
h.fillChannelsFromStore(&info, m.Name)
|
||||
out = append(out, info)
|
||||
h.logger().Warn("module describe skipped", "module", m.Name, "err", err)
|
||||
continue
|
||||
}
|
||||
|
|
@ -61,10 +69,14 @@ func (h *Handler) apps(w http.ResponseWriter, r *http.Request) {
|
|||
for _, ch := range d.Channels {
|
||||
info.Channels = append(info.Channels, channelInfo{ID: ch.ID, Label: ch.Label})
|
||||
}
|
||||
info.HasConfig = len(info.Channels) > 0
|
||||
if d.Rewriter != "" {
|
||||
info.Rewriter = d.Rewriter
|
||||
}
|
||||
// Older module binaries may not see the panel store; fill from module.yaml.
|
||||
if len(info.Channels) == 0 {
|
||||
h.fillChannelsFromStore(&info, m.Name)
|
||||
}
|
||||
info.HasConfig = len(info.Channels) > 0
|
||||
out = append(out, info)
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
|
|
@ -72,3 +84,53 @@ func (h *Handler) apps(w http.ResponseWriter, r *http.Request) {
|
|||
"rewriters": mpd.Names(),
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) fillChannelsFromStore(info *appInfo, name string) {
|
||||
if h == nil || h.Modules == nil || info == nil {
|
||||
return
|
||||
}
|
||||
chans := channelsFromStoreYAML(h.Modules, name)
|
||||
if len(chans) == 0 {
|
||||
return
|
||||
}
|
||||
info.Channels = chans
|
||||
info.HasConfig = true
|
||||
if info.Error != "" {
|
||||
// Soft: yaml channels recovered even though describe failed.
|
||||
info.Error = ""
|
||||
}
|
||||
}
|
||||
|
||||
// channelsFromStoreYAML reads channels from the panel module.yaml when describe
|
||||
// returns none (common with uploaded binaries that resolve values via cwd).
|
||||
func channelsFromStoreYAML(store *modstore.Store, name string) []channelInfo {
|
||||
if store == nil {
|
||||
return nil
|
||||
}
|
||||
raw, err := store.ReadYAML(name)
|
||||
if err != nil || len(raw) == 0 {
|
||||
return nil
|
||||
}
|
||||
var doc struct {
|
||||
Channels map[string]struct {
|
||||
Label string `yaml:"label"`
|
||||
} `yaml:"channels"`
|
||||
}
|
||||
if err := yaml.Unmarshal(raw, &doc); err != nil || len(doc.Channels) == 0 {
|
||||
return nil
|
||||
}
|
||||
ids := make([]string, 0, len(doc.Channels))
|
||||
for id := range doc.Channels {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
sort.Strings(ids)
|
||||
out := make([]channelInfo, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
label := doc.Channels[id].Label
|
||||
if label == "" {
|
||||
label = id
|
||||
}
|
||||
out = append(out, channelInfo{ID: id, Label: label})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue