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