diff --git a/main.go b/main.go index f796f4815d6..8856521b360 100644 --- a/main.go +++ b/main.go @@ -71,6 +71,7 @@ var ( keystorePass = app.Flag("storepass", "Password for certificate and keystore (optional).").PlaceHolder("PASS").String() caBundlePath = app.Flag("cacert", "Path to certificate authority bundle file (PEM/X509).").Required().String() timedReload = app.Flag("timed-reload", "Reload keystores every N seconds, refresh listener/client on changes.").PlaceHolder("N").Int() + shutdownTimeout = app.Flag("shutdown-timeout", "Graceful shutdown timeout. Terminates after timeout even if connections still open.").Default("5m").Duration() timeoutDuration = app.Flag("timeout", "Timeout for establishing connections, handshakes.").Default("10s").Duration() graphiteAddr = app.Flag("graphite", "Collect metrics and report them to the given graphite instance (raw TCP).").PlaceHolder("ADDR").TCP() metricsURL = app.Flag("metrics-url", "Collect metrics and POST them periodically to the given URL (via HTTP/JSON).").PlaceHolder("URL").String() diff --git a/signals.go b/signals.go index c0c974f21df..0441f8f5950 100644 --- a/signals.go +++ b/signals.go @@ -46,7 +46,7 @@ func serverSignalHandler(listener net.Listener, statusListener net.Listener, sto switch sig { case syscall.SIGTERM: logger.Printf("received SIGTERM, stopping listener") - time.AfterFunc(5*time.Minute, func() { + time.AfterFunc(*shutdownTimeout, func() { logger.Printf("graceful shutdown timeout: exiting") exitFunc(1) }) @@ -95,7 +95,7 @@ func clientSignalHandler(listener net.Listener, reloadClient chan bool, stopper switch sig { case syscall.SIGTERM: logger.Printf("received SIGTERM, stopping listener") - time.AfterFunc(5*time.Minute, func() { + time.AfterFunc(*shutdownTimeout, func() { logger.Printf("graceful shutdown timeout: exiting") exitFunc(1) })