diff --git a/CHANGELOG.md b/CHANGELOG.md index b494e9b847de..8b81781c36bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Main (unreleased) +- [ENHANCEMENT] Allow reloading configuration using `SIGHUP` signal. (@tharun208) + - [FEATURE] Add TLS config options for tempo `remote_write`s. (@mapno) - [FEATURE] Add support for OTLP HTTP trace exporting. (@mapno) diff --git a/cmd/agent/entrypoint.go b/cmd/agent/entrypoint.go index 98063dd92af1..6746bf7bd3bb 100644 --- a/cmd/agent/entrypoint.go +++ b/cmd/agent/entrypoint.go @@ -4,7 +4,10 @@ import ( "fmt" "net" "net/http" + "os" + "os/signal" "sync" + "syscall" "github.com/gorilla/mux" "github.com/grafana/agent/pkg/integrations" @@ -230,6 +233,14 @@ func (ep *Entrypoint) Start() error { // signal is received. signalHandler := signals.NewHandler(ep.cfg.Server.Log) + notifier := make(chan os.Signal) + signal.Notify(notifier, syscall.SIGHUP) + + defer func() { + signal.Stop(notifier) + close(notifier) + }() + g.Add(func() error { signalHandler.Loop() return nil @@ -251,5 +262,11 @@ func (ep *Entrypoint) Start() error { ep.srv.Close() }) + go func() { + for range notifier { + ep.TriggerReload() + } + }() + return g.Run() }