From ddddc0ba30114e8a9e8e9b709243ddbf21b79650 Mon Sep 17 00:00:00 2001 From: ameade <847570+ameade@users.noreply.github.com> Date: Fri, 20 Aug 2021 14:57:33 -0400 Subject: [PATCH] Do not exit with fatal when the http server successfully closes (#727) * Do not exit with fatal when the http server successfully closes * whitespace change Co-authored-by: Joe Webster --- frontend/metrics/plugin.go | 6 +++++- frontend/rest/apiserver_http.go | 5 ++++- frontend/rest/apiserver_https.go | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/metrics/plugin.go b/frontend/metrics/plugin.go index fd1562f77..24667b40b 100644 --- a/frontend/metrics/plugin.go +++ b/frontend/metrics/plugin.go @@ -38,7 +38,11 @@ func (s *Server) Activate() error { go func() { log.WithField("address", s.server.Addr).Info("Activating metrics frontend.") http.Handle("/metrics", s.server.Handler) - if err := s.server.ListenAndServe(); err != nil { + + err := s.server.ListenAndServe() + if err == http.ErrServerClosed { + log.WithField("address", s.server.Addr).Info("Metrics frontend server has closed.") + } else if err != nil { log.Fatal(err) } }() diff --git a/frontend/rest/apiserver_http.go b/frontend/rest/apiserver_http.go index 5b372f6e5..7f6592374 100644 --- a/frontend/rest/apiserver_http.go +++ b/frontend/rest/apiserver_http.go @@ -40,8 +40,11 @@ func NewHTTPServer(p core.Orchestrator, address, port string) *APIServerHTTP { func (s *APIServerHTTP) Activate() error { go func() { log.WithField("address", s.server.Addr).Info("Activating HTTP REST frontend.") + err := s.server.ListenAndServe() - if err != nil { + if err == http.ErrServerClosed { + log.WithField("address", s.server.Addr).Info("HTTP REST frontend server has closed.") + } else if err != nil { log.Fatal(err) } }() diff --git a/frontend/rest/apiserver_https.go b/frontend/rest/apiserver_https.go index 291c2cc1e..f1a270672 100644 --- a/frontend/rest/apiserver_https.go +++ b/frontend/rest/apiserver_https.go @@ -66,8 +66,11 @@ func NewHTTPSServer( func (s *APIServerHTTPS) Activate() error { go func() { log.WithField("address", s.server.Addr).Infof("Activating HTTPS REST frontend.") + err := s.server.ListenAndServeTLS(s.serverCertFile, s.serverKeyFile) - if err != nil { + if err == http.ErrServerClosed { + log.WithField("address", s.server.Addr).Info("HTTPS REST frontend server has closed.") + } else if err != nil { log.Fatal(err) } }()