mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
fix pprof.
This commit is contained in:
@@ -1,33 +0,0 @@
|
|||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/pprof"
|
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
|
||||||
)
|
|
||||||
|
|
||||||
const pprofPath = "/debug/pprof/"
|
|
||||||
|
|
||||||
func withPProf(router *chi.Mux) {
|
|
||||||
router.Route(pprofPath, func(r chi.Router) {
|
|
||||||
r.Get("/", pprof.Index)
|
|
||||||
|
|
||||||
r.Get("/{action}", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
action := chi.URLParam(r, "action")
|
|
||||||
|
|
||||||
switch action {
|
|
||||||
case "cmdline":
|
|
||||||
pprof.Cmdline(w, r)
|
|
||||||
case "profile":
|
|
||||||
pprof.Profile(w, r)
|
|
||||||
case "symbol":
|
|
||||||
pprof.Symbol(w, r)
|
|
||||||
case "trace":
|
|
||||||
pprof.Trace(w, r)
|
|
||||||
default:
|
|
||||||
pprof.Handler(action).ServeHTTP(w, r)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -58,12 +58,6 @@ func New(ApiManager types.ApiManager, roomConfig *config.Room, config *config.Se
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount pprof endpoint
|
|
||||||
if config.PProf {
|
|
||||||
withPProf(router)
|
|
||||||
logger.Info().Msgf("with pprof endpoint at %s", pprofPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// admin page
|
// admin page
|
||||||
//
|
//
|
||||||
@@ -240,6 +234,12 @@ func New(ApiManager types.ApiManager, roomConfig *config.Room, config *config.Se
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mount pprof endpoint
|
||||||
|
if config.PProf {
|
||||||
|
router.Mount("/debug", middleware.Profiler())
|
||||||
|
logger.Info().Msgf("with pprof endpoint")
|
||||||
|
}
|
||||||
|
|
||||||
// handle all remaining paths with proxy
|
// handle all remaining paths with proxy
|
||||||
router.Handle("/*", proxyHandler)
|
router.Handle("/*", proxyHandler)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user