agent: fix graceful http server shutdown

This commit is contained in:
Frank Schroeder 2017-06-02 22:21:51 +02:00 committed by Frank Schröder
parent ae711c3b04
commit 51e0e158f1
1 changed files with 1 additions and 6 deletions

View File

@ -1077,15 +1077,10 @@ func (a *Agent) Shutdown() error {
// no longer sufficient to check for an HTTPS server.
a.logger.Printf("[INFO] agent: Stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
// old behavior: just die
// srv.Close()
// graceful shutdown
// todo(fs): we are timing out every time. Need to find out why.
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
srv.Shutdown(ctx)
<-ctx.Done()
if ctx.Err() == context.DeadlineExceeded {
a.logger.Printf("[WARN] agent: Timeout stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
}