Live video on the AT Protocol

api_internal: add pprof handlers

See merge request aquareum-tv/aquareum!81

Changelog: feature

authored by

Eli Mallon and committed by
Eli Streams
7f70146e 00b74508

+16 -2
+14 -2
pkg/api/api_internal.go
··· 9 9 "io" 10 10 "log/slog" 11 11 "net/http" 12 + "net/http/pprof" 12 13 "os" 13 14 "regexp" 14 - "runtime/pprof" 15 + rtpprof "runtime/pprof" 15 16 "strconv" 16 17 "strings" 17 18 "time" ··· 63 64 triggerCollection := misttriggers.NewMistCallbackHandlersCollection(a.CLI, broker) 64 65 router.POST("/mist-trigger", triggerCollection.Trigger()) 65 66 router.HandlerFunc("GET", "/healthz", a.HandleHealthz(ctx)) 67 + 68 + // Add pprof handlers 69 + router.HandlerFunc("GET", "/debug/pprof/", pprof.Index) 70 + router.HandlerFunc("GET", "/debug/pprof/cmdline", pprof.Cmdline) 71 + router.HandlerFunc("GET", "/debug/pprof/profile", pprof.Profile) 72 + router.HandlerFunc("GET", "/debug/pprof/symbol", pprof.Symbol) 73 + router.HandlerFunc("GET", "/debug/pprof/trace", pprof.Trace) 74 + router.Handler("GET", "/debug/pprof/goroutine", pprof.Handler("goroutine")) 75 + router.Handler("GET", "/debug/pprof/heap", pprof.Handler("heap")) 76 + router.Handler("GET", "/debug/pprof/threadcreate", pprof.Handler("threadcreate")) 77 + router.Handler("GET", "/debug/pprof/block", pprof.Handler("block")) 66 78 67 79 router.GET("/playback/:user/concat", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { 68 80 user := p.ByName("user") ··· 210 222 211 223 // self-destruct code, useful for dumping goroutines on windows 212 224 router.POST("/abort", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { 213 - pprof.Lookup("goroutine").WriteTo(os.Stderr, 2) 225 + rtpprof.Lookup("goroutine").WriteTo(os.Stderr, 2) 214 226 log.Log(ctx, "got POST /abort, self-destructing") 215 227 os.Exit(1) 216 228 })
+2
pkg/cmd/aquareum.go
··· 66 66 } 67 67 } 68 68 if selfTest { 69 + runtime.GC() 70 + pprof.Lookup("goroutine").WriteTo(os.Stderr, 2) 69 71 fmt.Println("self-test successful!") 70 72 os.Exit(0) 71 73 }