Reputation: 3086
According to https://golang.org/pkg/net/http/#Server.Shutdown
Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down. If the provided context expires before the shutdown is complete, then the context's error is returned.
What does "then waiting indefinitely for connections to return to idle and then shut down" mean exactly? Should I expect that the context timeout should typically occur before this graceful shutdown finishes, given a timeout on the order of seconds?
Upvotes: 4
Views: 1089
Reputation: 6345
waiting indefinitely for connections to return to idle
refers to HTTP Handlers that have already been called as part of incoming connections. All these handlers need to be closed / returned, usually by calling w.Write or w.WriteHeader
Upvotes: 1