File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 66 "fmt"
77 "net"
88 "net/http"
9+ "net/http/pprof"
910 "os"
1011 "strconv"
1112 "strings"
@@ -30,6 +31,7 @@ func Init() {
3031 TLSCert string `yaml:"tls_cert"`
3132 TLSKey string `yaml:"tls_key"`
3233 UnixListen string `yaml:"unix_listen"`
34+ Pprof bool `yaml:"pprof"`
3335 } `yaml:"api"`
3436 }
3537
@@ -43,6 +45,9 @@ func Init() {
4345 return
4446 }
4547
48+ // overwrite default mux with new mux to avoid pprof auto registering
49+ http .DefaultServeMux = http .NewServeMux ()
50+
4651 basePath = cfg .Mod .BasePath
4752 log = app .GetLogger ("api" )
4853
@@ -54,6 +59,14 @@ func Init() {
5459 HandleFunc ("api/restart" , restartHandler )
5560 HandleFunc ("api/log" , logHandler )
5661
62+ if cfg .Mod .Pprof {
63+ HandleFunc ("/debug/pprof/" , pprof .Index )
64+ HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
65+ HandleFunc ("/debug/pprof/profile" , pprof .Profile )
66+ HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
67+ HandleFunc ("/debug/pprof/trace" , pprof .Trace )
68+ }
69+
5770 Handler = http .DefaultServeMux // 4th
5871
5972 if cfg .Mod .Origin == "*" {
You can’t perform that action at this time.
0 commit comments