From 3a33ece7d91cb82612a7de6b0cbeec2f87e5f03a Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 25 Jan 2026 09:38:52 -0800 Subject: [PATCH] Add SIGHUP handler to reload config file --- tendrils.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tendrils.go b/tendrils.go index db8f79b..115e11f 100644 --- a/tendrils.go +++ b/tendrils.go @@ -77,14 +77,28 @@ func (t *Tendrils) Run() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - sigCh := make(chan os.Signal, 1) - signal.Notify(sigCh, syscall.SIGUSR1) + sigUsr1Ch := make(chan os.Signal, 1) + signal.Notify(sigUsr1Ch, syscall.SIGUSR1) go func() { - for range sigCh { + for range sigUsr1Ch { t.nodes.LogAll() } }() + sigHupCh := make(chan os.Signal, 1) + signal.Notify(sigHupCh, syscall.SIGHUP) + go func() { + for range sigHupCh { + cfg, err := LoadConfig(t.ConfigFile) + if err != nil { + log.Printf("[ERROR] failed to reload config: %v", err) + continue + } + t.config = cfg + log.Printf("reloaded config from %s", t.ConfigFile) + } + }() + cfg, err := LoadConfig(t.ConfigFile) if err != nil { log.Printf("[ERROR] failed to load config: %v", err)