From 2d4a0347d6123431b3dc044ac66fc6abae161369 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 19 May 2026 00:39:38 +0000 Subject: [PATCH] Add pprof endpoint --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 97b4fe97..8b2e33e3 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" "net/http" + _ "net/http/pprof" "os" "os/signal" "runtime/debug" @@ -147,6 +148,20 @@ func main() { log.Debug().Str("report url", config.DomainRMO).Str("sync url", config.DomainNidus).Msg("Serving at URLs") + // Start pprof debug server on a separate port (localhost-only for security). + // Tunnels and Staging builds can set PPROF_BIND to override. + // Access via: curl http://localhost:6060/debug/pprof/goroutine?debug=1 + pprofBind := os.Getenv("PPROF_BIND") + if pprofBind == "" { + pprofBind = "localhost:6060" + } + go func() { + log.Info().Str("address", pprofBind).Msg("Starting pprof debug server") + if err := http.ListenAndServe(pprofBind, nil); err != nil { + log.Error().Err(err).Msg("pprof server stopped") + } + }() + openai_logger := log.With().Logger() err = llm.CreateOpenAIClient(ctx, &openai_logger) if err != nil {