Skip to content

Commit

Permalink
Objects with start / stop should not block
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Apr 10, 2019
1 parent 6ec665d commit 58844f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ func NewServer(addr string) *Server {

// Listens on the configured address and blocks until shutdown is called.
func (m Server) Start() {
if err := m.server.ListenAndServe(); err != http.ErrServerClosed {
log.Errorf("Can't start metrics HTTP server: %s", err)
}
go func() {
if err := m.server.ListenAndServe(); err != http.ErrServerClosed {
log.Errorf("Can't start metrics HTTP server: %s", err)
}
}()
}

// Shutdown gracefully shutdowns metrics http server waiting 5 seconds for
Expand Down

0 comments on commit 58844f9

Please sign in to comment.