diff --git a/util/profile/profile.go b/util/profile/profile.go new file mode 100644 index 00000000..74bfae6e --- /dev/null +++ b/util/profile/profile.go @@ -0,0 +1,19 @@ +package profile + +import ( + "log" + "net/http" + _ "net/http/pprof" + "os" +) + +func init() { + if httpAddr := os.Getenv("GOPROF"); httpAddr != "" { + go func() { + err := http.ListenAndServe(httpAddr, nil) + if err != nil { + log.Print(err) + } + }() + } +}