add -httpprofile option
parent
268703877b
commit
e30a94a934
|
@ -35,6 +35,7 @@ func init() {
|
|||
|
||||
var (
|
||||
cpuprofile = flag.String("cpuprofile", "", "filename of cpu profile output")
|
||||
httpprofile = flag.String("httpprofile", "", "bind address for profile server")
|
||||
memprofile = flag.String("memprofile", "", "dir name of mem profile output and interval (fname:interval)")
|
||||
cachedir = flag.String("cachedir", "/tmp/goposm", "cache directory")
|
||||
overwritecache = flag.Bool("overwritecache", false, "overwritecache")
|
||||
|
@ -77,6 +78,10 @@ func main() {
|
|||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
if *httpprofile != "" {
|
||||
stats.StartHttpPProf(*httpprofile)
|
||||
}
|
||||
|
||||
if *memprofile != "" {
|
||||
parts := strings.Split(*memprofile, string(os.PathListSeparator))
|
||||
var interval time.Duration
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package stats
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
func StartHttpPProf(bind string) {
|
||||
go func() {
|
||||
log.Println(http.ListenAndServe(bind, nil))
|
||||
}()
|
||||
}
|
Loading…
Reference in New Issue