Skip to content

Commit

Permalink
Do not exit with fatal when the http server successfully closes (#727)
Browse files Browse the repository at this point in the history
* Do not exit with fatal when the http server successfully closes
* whitespace change

Co-authored-by: Joe Webster <websterj@netapp.com>
  • Loading branch information
ameade and jwebster7 authored Aug 20, 2021
1 parent c72b82e commit ddddc0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion frontend/metrics/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down
5 changes: 4 additions & 1 deletion frontend/rest/apiserver_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down
5 changes: 4 additions & 1 deletion frontend/rest/apiserver_https.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down

0 comments on commit ddddc0b

Please sign in to comment.