Skip to content

Commit

Permalink
Add keep alive fix
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed Mar 22, 2018
1 parent 329c7fb commit 9f64d6c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ func listen(listener, controlListener net.Listener, err error) {
// handle dashboard registration and nonces if available
handleDashboardRegistration()

// Use a custom server so we can control keepalives
// Use a custom server so we can control tves
if config.Global.HttpServerOptions.OverrideDefaults {
mainRouter.SkipClean(config.Global.HttpServerOptions.SkipURLCleaning)

Expand All @@ -1200,6 +1200,10 @@ func listen(listener, controlListener net.Listener, err error) {
Handler: mainHandler{},
}

if config.Global.CloseConnections {
s.SetKeepAlivesEnabled(false)
}

// Accept connections in a new goroutine.
go s.Serve(listener)

Expand All @@ -1214,7 +1218,12 @@ func listen(listener, controlListener net.Listener, err error) {
} else {
mainLog.Printf("Gateway started (%s)", VERSION)

go http.Serve(listener, mainHandler{})
s := &http.Server{Handler: mainHandler{}}
if config.Global.CloseConnections {
s.SetKeepAlivesEnabled(false)
}

go s.Serve(listener)

if controlListener != nil {
go http.Serve(controlListener, controlRouter)
Expand Down Expand Up @@ -1252,6 +1261,10 @@ func listen(listener, controlListener net.Listener, err error) {
Handler: mainHandler{},
}

if config.Global.CloseConnections {
s.SetKeepAlivesEnabled(false)
}

mainLog.Info("Custom gateway started")
go s.Serve(listener)

Expand All @@ -1266,7 +1279,12 @@ func listen(listener, controlListener net.Listener, err error) {
} else {
mainLog.Printf("Gateway resumed (%s)", VERSION)

go http.Serve(listener, mainHandler{})
s := &http.Server{Handler: mainHandler{}}
if config.Global.CloseConnections {
s.SetKeepAlivesEnabled(false)
}

go s.Serve(listener)

if controlListener != nil {
mainLog.Info("Control API listener started: ", controlListener, controlRouter)
Expand Down

0 comments on commit 9f64d6c

Please sign in to comment.