diff --git a/changelog/radik878_fix-clieant-stats-shutdown.md b/changelog/radik878_fix-clieant-stats-shutdown.md new file mode 100644 index 000000000000..df7fd152223d --- /dev/null +++ b/changelog/radik878_fix-clieant-stats-shutdown.md @@ -0,0 +1,3 @@ +## Fixed + +- apply RunContext with signal-aware root context for graceful shutdown [#16056](https://github.com/OffchainLabs/prysm/pull/16056) diff --git a/cmd/client-stats/main.go b/cmd/client-stats/main.go index 4c5b582ff698..274bfa66e04d 100644 --- a/cmd/client-stats/main.go +++ b/cmd/client-stats/main.go @@ -1,9 +1,12 @@ package main import ( + "context" "fmt" "os" + "os/signal" runtimeDebug "runtime/debug" + "syscall" "time" "github.com/OffchainLabs/prysm/v7/cmd" @@ -100,7 +103,10 @@ func main() { } }() - if err := app.Run(os.Args); err != nil { + rctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + if err := app.RunContext(rctx, os.Args); err != nil { log.Error(err.Error()) } }