mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Add way to dynamically profile
Added new `--http-pprof` option, example: "--http-pprof :8181" It starts web server on given address, and expose special /debug/pprof endpoint See https://golang.org/pkg/net/http/pprof/
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
@@ -77,6 +78,12 @@ func main() {
|
||||
profileCPU(*cpuprofile)
|
||||
}
|
||||
|
||||
if Settings.pprof != "" {
|
||||
go func() {
|
||||
log.Println(http.ListenAndServe(Settings.pprof, nil))
|
||||
}()
|
||||
}
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
|
||||
@@ -30,6 +30,8 @@ type AppSettings struct {
|
||||
stats bool
|
||||
exitAfter time.Duration
|
||||
|
||||
pprof string
|
||||
|
||||
splitOutput bool
|
||||
|
||||
inputDummy MultiOption
|
||||
@@ -83,6 +85,7 @@ func usage() {
|
||||
func init() {
|
||||
flag.Usage = usage
|
||||
|
||||
flag.StringVar(&Settings.pprof, "http-pprof", "", "Enable profiling. Starts http server on specified port, exposing special /debug/pprof endpoint. Example: `:8181`")
|
||||
flag.BoolVar(&Settings.verbose, "verbose", false, "Turn on more verbose output")
|
||||
flag.BoolVar(&Settings.debug, "debug", false, "Turn on debug output, shows all intercepted traffic. Works only when with `verbose` flag")
|
||||
flag.BoolVar(&Settings.stats, "stats", false, "Turn on queue stats output")
|
||||
|
||||
Reference in New Issue
Block a user