fix(webconsole,monitor): pprof handlers of gorilla mux

This commit is contained in:
Zexi Li
2025-03-11 11:49:14 +08:00
parent 425b081ede
commit 9d2c172820
3 changed files with 27 additions and 34 deletions
+1 -22
View File
@@ -15,10 +15,8 @@
package service
import (
"context"
"net"
"net/http"
_ "net/http/pprof"
"net/url"
"os"
"strconv"
@@ -100,7 +98,7 @@ func start() {
root.Handle(WebsocketProxyPathPrefix, srv)
// misc handler
addMiscHandlers(app, root)
appsrv.AddMiscHandlersToMuxRouter(app, root, o.Options.EnableAppProfiling)
cron := cronman.InitCronJobManager(true, o.Options.CronJobWorkerCount, o.Options.TimeZone)
@@ -126,22 +124,3 @@ func start() {
}
}
}
func addMiscHandlers(app *appsrv.Application, root *mux.Router) {
adapterF := func(appHandleFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
appHandleFunc(app.GetContext(), w, r)
}
}
// ref: pkg/appsrv/appsrv:addDefaultHandlers
root.HandleFunc("/version", adapterF(appsrv.VersionHandler))
root.HandleFunc("/stats", adapterF(appsrv.StatisticHandler))
root.HandleFunc("/ping", adapterF(appsrv.PingHandler))
root.HandleFunc("/worker_stats", adapterF(appsrv.WorkerStatsHandler))
// pprof handler
if o.Options.EnableAppProfiling {
root.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
}
}