Added a memprofile dump flag and mechanism
This commit is contained in:
parent
6fd4138740
commit
a932d24683
11
control.go
11
control.go
@ -7,6 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
)
|
||||
@ -202,6 +203,16 @@ func killServer(w http.ResponseWriter, req *http.Request) {
|
||||
pprof.StopCPUProfile()
|
||||
log.Print("stopped cpu profile")
|
||||
}
|
||||
if *mprofile != "" {
|
||||
log.Print("trying to dump memory profile")
|
||||
f, err := os.Create(*mprofile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pprof.WriteHeapProfile(f)
|
||||
f.Close()
|
||||
log.Print("stopped memory profile dump")
|
||||
}
|
||||
log.Fatal("shit got fucked up")
|
||||
}
|
||||
|
||||
|
3
main.go
3
main.go
@ -15,7 +15,8 @@ import (
|
||||
|
||||
var addr = flag.String("addr", ":8666", "http service address")
|
||||
var profile = flag.String("pprof", "", "if specified will run with pprof")
|
||||
var netprofile = flag.Bool("netprof", false, "if specified will run with net/http/pprof")
|
||||
var mprofile = flag.String("mprof", "", "if specified will dump a memory profile")
|
||||
var netprofile = flag.Bool("netprof", false, "if specified will run with net/http/pprof on :8667")
|
||||
var verbose = flag.Bool("verbose", false, "")
|
||||
var config = flag.String("config", "~/.config/hackerbots/config.json", "location of config file")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user