From 0f54e0fb15c7c30bc7e87e6f9a7d16ad1cd2c8d1 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Sun, 21 Feb 2021 15:52:01 +0300 Subject: [PATCH] Fix copy-by-value of sync.Lock in the monitoring server struct --- pkg/monitoring/monitoring.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/monitoring/monitoring.go b/pkg/monitoring/monitoring.go index ff528200..08f22bba 100644 --- a/pkg/monitoring/monitoring.go +++ b/pkg/monitoring/monitoring.go @@ -16,7 +16,7 @@ import ( type ServerMonitoring struct { cfg monitoring.ServerMonitoringConfig tag string - server http.Server + server *http.Server } func NewServerMonitoring(cfg monitoring.ServerMonitoringConfig, tag string) *ServerMonitoring { @@ -37,6 +37,7 @@ func (sm *ServerMonitoring) Run() error { Addr: fmt.Sprintf(":%d", sm.cfg.Port), Handler: monitoringServerMux, } + sm.server = &srv glog.Infof("[%v] Starting monitoring server at %v", sm.tag, srv.Addr) if sm.cfg.ProfilingEnabled { @@ -62,7 +63,6 @@ func (sm *ServerMonitoring) Run() error { glog.Infof("[%v] Prometheus metric is enabled at %v", sm.tag, srv.Addr+metricPath) monitoringServerMux.Handle(metricPath, promhttp.Handler()) } - sm.server = srv return srv.ListenAndServe() } return nil