|
@@ -5,6 +5,8 @@ import (
|
|
|
"crypto/md5"
|
|
|
"encoding/hex"
|
|
|
"net"
|
|
|
+ hp "net/http"
|
|
|
+ "net/http/pprof"
|
|
|
"os"
|
|
|
"os/signal"
|
|
|
"runtime"
|
|
@@ -231,6 +233,17 @@ func (svr *Service) startHttpServe() (err error) {
|
|
|
"uptime": time.Now().Sub(svr.upTime).String(),
|
|
|
})
|
|
|
})
|
|
|
+ if svr.opts.EnableHttpPProf {
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/", hp.HandlerFunc(pprof.Index))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/goroutine", hp.HandlerFunc(pprof.Index))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/heap", hp.HandlerFunc(pprof.Index))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/mutex", hp.HandlerFunc(pprof.Index))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/threadcreate", hp.HandlerFunc(pprof.Index))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/cmdline", hp.HandlerFunc(pprof.Cmdline))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/profile", hp.HandlerFunc(pprof.Profile))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/symbol", hp.HandlerFunc(pprof.Symbol))
|
|
|
+ svr.httpSvr.Handler("GET", "/debug/pprof/trace", hp.HandlerFunc(pprof.Trace))
|
|
|
+ }
|
|
|
log.Infof("attach http server success")
|
|
|
} else {
|
|
|
log.Warnf("attach http listener error: %s", err.Error())
|