pprof configuration support, #382

This commit is contained in:
ffdfgdfg
2020-02-09 16:54:40 +08:00
parent 704bba92d1
commit 533dd083fe
9 changed files with 49 additions and 0 deletions

29
lib/common/pprof.go Normal file
View File

@@ -0,0 +1,29 @@
package common
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"net/http"
_ "net/http/pprof"
)
func InitPProfFromFile() {
ip := beego.AppConfig.String("pprof_ip")
p := beego.AppConfig.String("pprof_port")
if len(ip) > 0 && len(p) > 0 && IsPort(p) {
runPProf(ip + ":" + p)
}
}
func InitPProfFromArg(arg string) {
if len(arg) > 0 {
runPProf(arg)
}
}
func runPProf(ipPort string) {
go func() {
_ = http.ListenAndServe(ipPort, nil)
}()
logs.Info("PProf debug listen on", ipPort)
}

View File

@@ -145,6 +145,8 @@ func dealCommon(s string) *CommonConfig {
c.Client.MaxConn = common.GetIntNoErrByStr(item[1])
case "remark":
c.Client.Remark = item[1]
case "pprof_addr":
common.InitPProfFromArg(item[1])
}
}
return c