Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: shutdown the actual http server #1689

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions pkg/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package server

import (
"context"
"net"
"net/http"
"net/http/pprof"
"time"
Expand All @@ -22,9 +21,8 @@ type Server struct {
comp component.Component
prober *prober.Prober

mux *http.ServeMux
srv *http.Server
listener net.Listener
mux *http.ServeMux
srv *http.Server

opts options
}
Expand Down Expand Up @@ -55,15 +53,9 @@ func NewHTTP(logger log.Logger, reg *prometheus.Registry, comp component.Compone
}

func (s *Server) ListenAndServe() error {
l, err := net.Listen("tcp", s.opts.listen)
if err != nil {
return errors.Wrap(err, "listen metrics address")
}
s.listener = l
s.prober.SetHealthy()
level.Info(s.logger).Log("msg", "listening for requests and metrics", "component", s.comp.String(), "address", s.opts.listen)

return errors.Wrapf(http.Serve(l, s.mux), "serve %s and metrics", s.comp.String())
return errors.Wrapf(s.srv.ListenAndServe(), "serve %s and metrics", s.comp.String())
}

func (s *Server) Shutdown(err error) {
Expand Down