Add timeouts to http server and additional pprof routes

This commit is contained in:
Manuel de Brito Fontes 2017-11-18 07:11:15 -03:00
parent de37e8ea89
commit c53fe01fad

View file

@ -302,6 +302,12 @@ 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)
@ -310,6 +316,8 @@ func registerHandlers(enableProfiling bool, port int, ic *controller.NGINXContro
server := &http.Server{
Addr: fmt.Sprintf(":%v", port),
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
}
glog.Fatal(server.ListenAndServe())
}