Skip normal ErrServerClosed errors

This commit is contained in:
Sergey Stepanov 2021-02-21 16:13:29 +03:00
parent 0f54e0fb15
commit 98ca6e7ace
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
2 changed files with 12 additions and 2 deletions

View file

@ -63,12 +63,22 @@ func (sm *ServerMonitoring) Run() error {
glog.Infof("[%v] Prometheus metric is enabled at %v", sm.tag, srv.Addr+metricPath)
monitoringServerMux.Handle(metricPath, promhttp.Handler())
}
return srv.ListenAndServe()
err := srv.ListenAndServe()
if err == http.ErrServerClosed {
glog.Infof("[%v] The main HTTP server has been closed", sm.tag)
return nil
}
return err
}
return nil
}
func (sm *ServerMonitoring) Shutdown(ctx context.Context) error {
if sm.server == nil {
return nil
}
glog.Infof("[%v] Shutting down monitoring server", sm.tag)
return sm.server.Shutdown(ctx)
}

View file

@ -58,7 +58,7 @@ func (wrk *Worker) startModules() {
return
}
if err := s.Run(); err != nil {
glog.Errorf("failed start server")
glog.Errorf("failed start server: [%v]", err)
}
}()
}