Skip to content

Commit

Permalink
Add server timeouts (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPelletier committed Jan 27, 2024
1 parent 80d53d5 commit 75064a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cmds/core-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,12 @@ func RunHTTPServer(ctx context.Context, ctxCanceler func(), address, locality st
))

httpServer := &http.Server{
Addr: address,
Handler: handler,
Addr: address,
Handler: handler,
ReadHeaderTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 30 * time.Second,
}

signals := make(chan os.Signal, 1)
Expand Down
8 changes: 6 additions & 2 deletions cmds/dummy-oauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ func main() {
router := dummyoauth.MakeAPIRouter(&impl, &PermissiveAuthorizer{})
multiRouter := api.MultiRouter{Routers: []api.PartialRouter{&router}}
s := &http.Server{
Addr: *address,
Handler: &multiRouter,
Addr: *address,
Handler: &multiRouter,
ReadHeaderTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 30 * time.Second,
}
log.Fatal(s.ListenAndServe())
}

0 comments on commit 75064a5

Please sign in to comment.