docker: close idle connections on stop

This commit is contained in:
Frank Schroeder 2017-10-26 11:57:18 +02:00
parent 94726ef105
commit e774b46f82
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
2 changed files with 8 additions and 0 deletions

View File

@ -573,6 +573,7 @@ func (c *CheckDocker) Stop() {
}
func (c *CheckDocker) run() {
defer c.Client.Close()
firstWait := lib.RandomStagger(c.Interval)
next := time.After(firstWait)
for {

View File

@ -54,6 +54,13 @@ func NewDockerClient(host string, maxbuf int64) (*DockerClient, error) {
}, nil
}
func (c *DockerClient) Close() error {
if t, ok := c.client.Transport.(*http.Transport); ok {
t.CloseIdleConnections()
}
return nil
}
func (c *DockerClient) Host() string {
return c.host
}