Merge pull request #1723 from aledbf/timoeuts

Add timeouts to http server and additional pprof routes
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-11-18 07:33:14 -03:00 committed by GitHub
commit 99d68803da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -302,14 +302,22 @@ func registerHandlers(enableProfiling bool, port int, ic *controller.NGINXContro
if enableProfiling { if enableProfiling {
mux.HandleFunc("/debug/pprof/", pprof.Index) 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/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace) mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
} }
server := &http.Server{ server := &http.Server{
Addr: fmt.Sprintf(":%v", port), Addr: fmt.Sprintf(":%v", port),
Handler: mux, Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
} }
glog.Fatal(server.ListenAndServe()) glog.Fatal(server.ListenAndServe())
} }