pprof.go 520 B

1234567891011121314151617181920212223242526272829
  1. package common
  2. import (
  3. "github.com/astaxie/beego"
  4. "github.com/astaxie/beego/logs"
  5. "net/http"
  6. _ "net/http/pprof"
  7. )
  8. func InitPProfFromFile() {
  9. ip := beego.AppConfig.String("pprof_ip")
  10. p := beego.AppConfig.String("pprof_port")
  11. if len(ip) > 0 && len(p) > 0 && IsPort(p) {
  12. runPProf(ip + ":" + p)
  13. }
  14. }
  15. func InitPProfFromArg(arg string) {
  16. if len(arg) > 0 {
  17. runPProf(arg)
  18. }
  19. }
  20. func runPProf(ipPort string) {
  21. go func() {
  22. _ = http.ListenAndServe(ipPort, nil)
  23. }()
  24. logs.Info("PProf debug listen on", ipPort)
  25. }