Skip to content

Commit

Permalink
add flag for HTTP idle connection timeout value (#1597)
Browse files Browse the repository at this point in the history
* add flag for HTTP idle connection timeout value

Signed-off-by: Bob Callaway <[email protected]>

* leave default behavior as-is

Signed-off-by: Bob Callaway <[email protected]>

* Only update `http.Server.IdleTimeout` when `http_idle_timeout` flag is set

---------

Signed-off-by: Bob Callaway <[email protected]>
Co-authored-by: Roger Ng <[email protected]>
  • Loading branch information
bobcallaway and roger2hk authored Oct 30, 2024
1 parent dc370ba commit ce9bc5c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trillian/ctfe/ct_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
// Global flags that affect all log instances.
var (
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port)")
httpIdleTimeout = flag.Duration("http_idle_timeout", -1*time.Second, "Timeout after which idle connections will be closed by server")
tlsCert = flag.String("tls_certificate", "", "Path to server TLS certificate")
tlsKey = flag.String("tls_key", "", "Path to server TLS private key")
metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint")
Expand Down Expand Up @@ -334,6 +335,10 @@ func main() {
} else {
srv = http.Server{Addr: *httpEndpoint, Handler: handler}
}
if *httpIdleTimeout > 0 {
srv.IdleTimeout = *httpIdleTimeout
}

shutdownWG := new(sync.WaitGroup)
go awaitSignal(func() {
shutdownWG.Add(1)
Expand Down

0 comments on commit ce9bc5c

Please sign in to comment.