Remove memprofile file, add pprof HTTP endpoint instead.

pull/53/head
Julius Volz 10 years ago
parent 0c8bfba04d
commit a730cff002

@ -6,9 +6,9 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
_ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"runtime/pprof"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
@ -171,7 +171,7 @@ func main() {
password: *authPass, password: *authPass,
} }
} }
go func() {
http.Handle(*metricsPath, handler) http.Handle(*metricsPath, handler)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html> w.Write([]byte(`<html>
@ -182,26 +182,8 @@ func main() {
</body> </body>
</html>`)) </html>`))
}) })
err := http.ListenAndServe(*listenAddress, nil) err = http.ListenAndServe(*listenAddress, nil)
if err != nil {
glog.Fatal(err)
}
}()
for {
select {
case <-sigUsr1:
glog.Infof("got signal")
if *memProfile != "" {
glog.Infof("Writing memory profile to %s", *memProfile)
f, err := os.Create(*memProfile)
if err != nil { if err != nil {
glog.Fatal(err) glog.Fatal(err)
} }
pprof.WriteHeapProfile(f)
f.Close()
}
}
}
} }

Loading…
Cancel
Save