From c53fe01fad3c44499565cf806ede5254b7f4648f Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sat, 18 Nov 2017 07:11:15 -0300 Subject: [PATCH] Add timeouts to http server and additional pprof routes --- cmd/nginx/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/nginx/main.go b/cmd/nginx/main.go index ee8d88d04..deb7ad61f 100644 --- a/cmd/nginx/main.go +++ b/cmd/nginx/main.go @@ -302,14 +302,22 @@ func registerHandlers(enableProfiling bool, port int, ic *controller.NGINXContro if enableProfiling { mux.HandleFunc("/debug/pprof/", pprof.Index) + mux.HandleFunc("/debug/pprof/heap", pprof.Index) + mux.HandleFunc("/debug/pprof/mutex", pprof.Index) + mux.HandleFunc("/debug/pprof/goroutine", pprof.Index) + mux.HandleFunc("/debug/pprof/threadcreate", pprof.Index) + mux.HandleFunc("/debug/pprof/block", pprof.Index) + mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("/debug/pprof/profile", pprof.Profile) mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) } server := &http.Server{ - Addr: fmt.Sprintf(":%v", port), - Handler: mux, + Addr: fmt.Sprintf(":%v", port), + Handler: mux, + ReadTimeout: 10 * time.Second, + WriteTimeout: 30 * time.Second, } glog.Fatal(server.ListenAndServe()) }