diff --git a/internal/driver/webui.go b/internal/driver/webui.go index ac7465c9..21bb62aa 100644 --- a/internal/driver/webui.go +++ b/internal/driver/webui.go @@ -210,6 +210,9 @@ func defaultWebServer(args *plugin.HTTPServerArgs) error { mux := http.NewServeMux() mux.Handle("/ui/", http.StripPrefix("/ui", handler)) mux.Handle("/", redirectWithQuery("/ui", http.StatusTemporaryRedirect)) + // Enable self-profiling handlers if net/http/pprof is imported by the main + // program. + mux.HandleFunc("/debug/pprof/", http.DefaultServeMux.ServeHTTP) s := &http.Server{Handler: mux} return s.Serve(ln) } diff --git a/pprof.go b/pprof.go index fcb74123..a2c628d0 100644 --- a/pprof.go +++ b/pprof.go @@ -24,6 +24,8 @@ import ( "github.com/chzyer/readline" "github.com/google/pprof/driver" + + _ "net/http/pprof" // Enable profiling pprof itself in the web UI mode. ) func main() {