add -httpprofile option

master
Oliver Tonnhofer 2013-05-30 16:18:48 +02:00
parent 268703877b
commit e30a94a934
2 changed files with 18 additions and 0 deletions

View File

@ -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

13
stats/http.go Normal file
View File

@ -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))
}()
}