Skip to content

Commit

Permalink
Add some reasonable timeouts to API server (#337)
Browse files Browse the repository at this point in the history
Fixes #336

Signed-off-by: Nathan Smith <nathan@nfsmith.ca>
  • Loading branch information
nsmith5 committed Jan 21, 2022
1 parent f024a03 commit 50b605d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -206,6 +207,12 @@ func runServeCmd(cmd *cobra.Command, args []string) {
api := http.Server{
Addr: host + ":" + port,
Handler: handler,

// Timeouts
ReadTimeout: 60 * time.Second,
ReadHeaderTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
IdleTimeout: 60 * time.Second,
}

if err := api.ListenAndServe(); err != nil && err != http.ErrServerClosed {
Expand Down

0 comments on commit 50b605d

Please sign in to comment.