mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
pprof configuration support, #382
This commit is contained in:
29
lib/common/pprof.go
Normal file
29
lib/common/pprof.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user