From df24c1268e9ba09ecd4939afbaeb66ba582057d1 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 26 Jul 2022 17:19:30 +0300 Subject: [PATCH] cli: restart pprof and prometheus on HUP --- cli/server/server.go | 6 ++++++ pkg/services/metrics/metrics.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/cli/server/server.go b/cli/server/server.go index 248ac67e8..42b699bd8 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -551,6 +551,12 @@ Main: if !cfgnew.ApplicationConfiguration.RPC.StartWhenSynchronized || serv.IsInSync() { rpcServer.Start() } + pprof.ShutDown() + pprof = metrics.NewPprofService(cfgnew.ApplicationConfiguration.Pprof, log) + go pprof.Start() + prometheus.ShutDown() + prometheus = metrics.NewPrometheusService(cfgnew.ApplicationConfiguration.Prometheus, log) + go prometheus.Start() } cfg = cfgnew case <-grace.Done(): diff --git a/pkg/services/metrics/metrics.go b/pkg/services/metrics/metrics.go index 071c1fbeb..b3cb4c27b 100644 --- a/pkg/services/metrics/metrics.go +++ b/pkg/services/metrics/metrics.go @@ -31,6 +31,9 @@ func (ms *Service) Start() { // ShutDown stops the service. func (ms *Service) ShutDown() { + if !ms.config.Enabled { + return + } ms.log.Info("shutting down service", zap.String("endpoint", ms.Addr)) err := ms.Shutdown(context.Background()) if err != nil {