Add request accepting grace period delaying graceful shutdown.

This commit is contained in:
Timo Reimann 2017-09-26 10:22:03 +02:00 committed by Traefiker
parent fc550ac1fc
commit 1c98a9ad3e
10 changed files with 251 additions and 38 deletions

View file

@ -5,6 +5,7 @@ package server
import (
"os/signal"
"syscall"
"time"
"github.com/containous/traefik/log"
)
@ -31,7 +32,12 @@ func (server *Server) listenSignals() {
}
default:
log.Infof("I have to go... %+v", sig)
log.Info("Stopping server")
reqAcceptGraceTimeOut := time.Duration(server.globalConfiguration.LifeCycle.RequestAcceptGraceTimeout)
if reqAcceptGraceTimeOut > 0 {
log.Infof("Waiting %s for incoming requests to cease", reqAcceptGraceTimeOut)
time.Sleep(reqAcceptGraceTimeOut)
}
log.Info("Stopping server gracefully")
server.Stop()
}
}