Skip to content

Commit

Permalink
Revert "server: register all status routes with mux.Router (#51915)"
Browse files Browse the repository at this point in the history
This reverts commit 9855a55.
  • Loading branch information
hawkingrei committed Mar 29, 2024
1 parent b1c0e36 commit b68cc05
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/server/http_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,14 @@ func (s *Server) startHTTPServer() {
router.PathPrefix("/static/").Handler(http.StripPrefix("/static", http.FileServer(static.Data)))
}

router.HandleFunc("/debug/pprof/", pprof.Index)
router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
router.HandleFunc("/debug/pprof/profile", cpuprofile.ProfileHTTPHandler)
router.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
router.HandleFunc("/debug/pprof/trace", pprof.Trace)
serverMux := http.NewServeMux()
serverMux.Handle("/", router)

serverMux.HandleFunc("/debug/pprof/", pprof.Index)
serverMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
serverMux.HandleFunc("/debug/pprof/profile", cpuprofile.ProfileHTTPHandler)
serverMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
serverMux.HandleFunc("/debug/pprof/trace", pprof.Trace)

ballast := newBallast(s.cfg.MaxBallastObjectSize)
{
Expand All @@ -307,9 +310,9 @@ func (s *Server) startHTTPServer() {
logutil.BgLogger().Error("set initial ballast object size failed", zap.Error(err))
}
}
router.HandleFunc("/debug/ballast-object-sz", ballast.GenHTTPHandler())
serverMux.HandleFunc("/debug/ballast-object-sz", ballast.GenHTTPHandler())

router.HandleFunc("/debug/gogc", func(w http.ResponseWriter, r *http.Request) {
serverMux.HandleFunc("/debug/gogc", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
_, err := w.Write([]byte(strconv.Itoa(util.GetGOGC())))
Expand All @@ -334,7 +337,7 @@ func (s *Server) startHTTPServer() {
}
})

router.HandleFunc("/debug/zip", func(w http.ResponseWriter, r *http.Request) {
serverMux.HandleFunc("/debug/zip", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="tidb_debug"`+time.Now().Format("20060102150405")+".zip"))

// dump goroutine/heap/mutex
Expand Down Expand Up @@ -420,7 +423,7 @@ func (s *Server) startHTTPServer() {

// failpoint is enabled only for tests so we can add some http APIs here for tests.
failpoint.Inject("enableTestAPI", func() {
router.HandleFunc("/fail/", func(w http.ResponseWriter, r *http.Request) {
serverMux.HandleFunc("/fail/", func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/fail")
new(failpoint.HttpHandler).ServeHTTP(w, r)
})
Expand Down Expand Up @@ -464,9 +467,6 @@ func (s *Server) startHTTPServer() {
logutil.BgLogger().Error("write HTTP index page failed", zap.Error(err))
}
})

serverMux := http.NewServeMux()
serverMux.Handle("/", router)
s.startStatusServerAndRPCServer(serverMux)
}

Expand Down

0 comments on commit b68cc05

Please sign in to comment.