From 03be65ee9944771b720982de28cfc20ba448518d Mon Sep 17 00:00:00 2001 From: Mitchell-Johnson Date: Fri, 18 Sep 2026 17:47:16 -0700 Subject: [PATCH] pprof behind the login for memory investigation Co-Authored-By: Claude Fable 5.1 --- internal/api/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/api/server.go b/internal/api/server.go index 5c0e2b2..2342e7f 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -12,6 +12,7 @@ import ( "mime" "net" "net/http" + "net/http/pprof" "net/url" "os" "os/exec" @@ -148,6 +149,11 @@ func New(cfg *config.Config, sessions *auth.Sessions, mgr *term.Manager, col *me m.HandleFunc("POST /api/password", s.auth(s.changePassword)) m.HandleFunc("GET /api/prefs/ui", s.auth(s.getUIPrefs)) m.HandleFunc("PUT /api/prefs/ui", s.auth(s.putUIPrefs)) + // Go runtime profiles, behind the login, for chasing memory/CPU (bug 14). + m.Handle("/api/debug/pprof/", s.auth(func(w http.ResponseWriter, r *http.Request) { + r.URL.Path = strings.TrimPrefix(r.URL.Path, "/api") + pprof.Index(w, r) + })) m.HandleFunc("GET /api/prefs/dashboard", s.auth(s.getDashPrefs)) m.HandleFunc("PUT /api/prefs/dashboard", s.auth(s.putDashPrefs)) m.HandleFunc("/api/", func(w http.ResponseWriter, _ *http.Request) { jsonErr(w, 404, "not found") })