mirror of
https://github.com/status-im/consul.git
synced 2025-02-16 15:47:21 +00:00
agent: fix graceful http server shutdown
This commit is contained in:
parent
ae711c3b04
commit
51e0e158f1
@ -1077,15 +1077,10 @@ func (a *Agent) Shutdown() error {
|
|||||||
// no longer sufficient to check for an HTTPS server.
|
// no longer sufficient to check for an HTTPS server.
|
||||||
a.logger.Printf("[INFO] agent: Stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
|
a.logger.Printf("[INFO] agent: Stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
|
||||||
|
|
||||||
// old behavior: just die
|
|
||||||
// srv.Close()
|
|
||||||
|
|
||||||
// graceful shutdown
|
// graceful shutdown
|
||||||
// todo(fs): we are timing out every time. Need to find out why.
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
|
||||||
defer cancel()
|
defer cancel()
|
||||||
srv.Shutdown(ctx)
|
srv.Shutdown(ctx)
|
||||||
<-ctx.Done()
|
|
||||||
if ctx.Err() == context.DeadlineExceeded {
|
if ctx.Err() == context.DeadlineExceeded {
|
||||||
a.logger.Printf("[WARN] agent: Timeout stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
|
a.logger.Printf("[WARN] agent: Timeout stopping %s server %s", strings.ToUpper(srv.proto), srv.Addr)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user