diff --git a/main.go b/main.go index 0b4fa90d..882bd944 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ import ( "log" "net" "net/http" - _ "net/http/pprof" + "net/http/pprof" "os" "os/signal" "runtime" @@ -160,6 +160,9 @@ func main() { r.Handler("GET", "/status", statusHandler) r.Handler("GET", "/", statusHandler) + // Re-enable pprof. + r.GET("/debug/pprof/*pprof", handlePprof) + log.Printf("Listening on %s.\n", *addr) l, err := net.Listen("tcp", *addr) if err != nil { @@ -177,6 +180,19 @@ func main() { } } +func handlePprof(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + switch p.ByName("pprof") { + case "/cmdline": + pprof.Cmdline(w, r) + case "/profile": + pprof.Profile(w, r) + case "/symbol": + pprof.Symbol(w, r) + default: + pprof.Index(w, r) + } +} + func interruptHandler(l net.Listener) { notifier := make(chan os.Signal) signal.Notify(notifier, os.Interrupt, syscall.SIGTERM)