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"
@@ -32,6 +33,7 @@ func Init() {
3233 TLSCert string `yaml:"tls_cert"`
3334 TLSKey string `yaml:"tls_key"`
3435 UnixListen string `yaml:"unix_listen"`
36+ Pprof bool `yaml:"pprof"`
3537 } `yaml:"api"`
3638 }
3739
@@ -45,6 +47,9 @@ func Init() {
4547 return
4648 }
4749
50+ // overwrite default mux with new mux to avoid pprof auto registering
51+ http .DefaultServeMux = http .NewServeMux ()
52+
4853 basePath = cfg .Mod .BasePath
4954 log = app .GetLogger ("api" )
5055
@@ -56,6 +61,14 @@ func Init() {
5661 HandleFunc ("api/restart" , restartHandler )
5762 HandleFunc ("api/log" , logHandler )
5863
64+ if cfg .Mod .Pprof {
65+ HandleFunc ("/debug/pprof/" , pprof .Index )
66+ HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
67+ HandleFunc ("/debug/pprof/profile" , pprof .Profile )
68+ HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
69+ HandleFunc ("/debug/pprof/trace" , pprof .Trace )
70+ }
71+
5972 Handler = http .DefaultServeMux // 4th
6073
6174 if cfg .Mod .Origin == "*" {
You can’t perform that action at this time.
0 commit comments