mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
add profiler support
profiling is now available via the HTTP base URL /debug/pprof/ examples, use this URL to start and download a 30 seconds CPU profile: /debug/pprof/profile?seconds=30 use this URL to profile used memory: /debug/pprof/heap?gc=1 use this URL to profile allocated memory: /debug/pprof/allocs?gc=1 Full docs here: https://golang.org/pkg/net/http/pprof/
This commit is contained in:
@@ -18,13 +18,19 @@ func GetHTTPRouter() http.Handler {
|
||||
return router
|
||||
}
|
||||
|
||||
func initializeRouter(staticFilesPath string) {
|
||||
func initializeRouter(staticFilesPath string, profiler bool) {
|
||||
router = chi.NewRouter()
|
||||
router.Use(middleware.RequestID)
|
||||
router.Use(middleware.RealIP)
|
||||
router.Use(logger.NewStructuredLogger(logger.GetLogger()))
|
||||
router.Use(middleware.Recoverer)
|
||||
|
||||
if profiler {
|
||||
logger.InfoToConsole("enabling the built-in profiler")
|
||||
logger.Info(logSender, "", "enabling the built-in profiler")
|
||||
router.Mount(pprofBasePath, middleware.Profiler())
|
||||
}
|
||||
|
||||
router.NotFound(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
sendAPIResponse(w, r, nil, "Not Found", http.StatusNotFound)
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user