Skip to content

Commit de48b16

Browse files
Add pprof
1 parent ac53884 commit de48b16

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gotty/server/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log"
1010
"net"
1111
"net/http"
12+
"net/http/pprof"
1213
"os"
1314
"regexp"
1415
noesctmpl "text/template"
@@ -210,6 +211,14 @@ func (server *Server) setupHandlers(ctx context.Context, cancel context.CancelFu
210211
if len(os.Getenv("TERMINAL_PATH")) < 1 {
211212
siteMux.HandleFunc("/", server.handleMain)
212213
}
214+
215+
if pprofEnabled := os.Getenv("PPROF_ENABLED"); pprofEnabled != "" {
216+
siteMux.HandleFunc("/debug/pprof/", pprof.Index)
217+
siteMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
218+
siteMux.HandleFunc("/debug/pprof/profile", pprof.Profile)
219+
siteMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
220+
siteMux.HandleFunc("/debug/pprof/trace", pprof.Trace)
221+
}
213222
siteHandler := http.Handler(siteMux)
214223

215224
if server.options.EnableBasicAuth {

0 commit comments

Comments
 (0)