From 6ae561b9686ca62a87cd5ee0cad43d7bd8e3256d Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 28 Jan 2026 08:30:23 -0800 Subject: [PATCH] Include config in status response and push on SIGHUP Co-Authored-By: Claude Opus 4.5 --- http.go | 16 ++++++---------- static/index.html | 7 ++----- tendrils.go | 1 + 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/http.go b/http.go index ce2882d..81d0ad9 100644 --- a/http.go +++ b/http.go @@ -25,6 +25,7 @@ const ( ) type StatusResponse struct { + Config *Config `json:"config"` Nodes []*Node `json:"nodes"` Links []*Link `json:"links"` MulticastGroups []*MulticastGroupMembers `json:"multicast_groups"` @@ -45,7 +46,6 @@ func (t *Tendrils) startHTTPServer() { mux := http.NewServeMux() mux.HandleFunc("/api/status", t.handleAPIStatus) mux.HandleFunc("/api/status/stream", t.handleAPIStatusStream) - mux.HandleFunc("/api/config", t.handleAPIConfig) mux.HandleFunc("/api/errors/clear", t.handleClearError) mux.Handle("/", http.FileServer(http.Dir("static"))) @@ -124,22 +124,18 @@ func (t *Tendrils) handleAPIStatus(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(status) } -func (t *Tendrils) handleAPIConfig(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - if t.config == nil { - json.NewEncoder(w).Encode(&Config{}) - return - } - json.NewEncoder(w).Encode(t.config) -} - func (t *Tendrils) GetStatus() *StatusResponse { var broadcastStats *BroadcastStatsResponse if t.broadcast != nil { stats := t.broadcast.GetStats() broadcastStats = &stats } + config := t.config + if config == nil { + config = &Config{} + } return &StatusResponse{ + Config: config, Nodes: t.getNodes(), Links: t.getLinks(), MulticastGroups: t.getMulticastGroups(), diff --git a/static/index.html b/static/index.html index a14f2bb..08afd0a 100644 --- a/static/index.html +++ b/static/index.html @@ -1725,13 +1725,10 @@ }, 10000); } - evtSource.addEventListener('status', async (event) => { + evtSource.addEventListener('status', (event) => { resetHeartbeat(); const data = JSON.parse(event.data); - if (!currentConfig) { - const configResp = await fetch('/api/config'); - currentConfig = await configResp.json(); - } + currentConfig = data.config || {}; render(data, currentConfig); }); diff --git a/tendrils.go b/tendrils.go index 052bf45..409fc82 100644 --- a/tendrils.go +++ b/tendrils.go @@ -142,6 +142,7 @@ func (t *Tendrils) Run() { } t.config = cfg log.Printf("reloaded config from %s", t.ConfigFile) + t.NotifyUpdate() } }()