diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-20 06:41:08 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-20 06:41:08 +0300 |
| commit | b679462fa687b375ccefd3c11fec3fd96b9b4d60 (patch) | |
| tree | 62539ed177a1dfcf92347737179ea1054401c9bd /cmd/dgrep | |
| parent | 5b56cb675fb3b7ad58c5de28760bc19f63a575bb (diff) | |
make pprof bind address configurable
Diffstat (limited to 'cmd/dgrep')
| -rw-r--r-- | cmd/dgrep/main.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 602d318..02b2463 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "os" "sync" @@ -25,7 +24,7 @@ func main() { var args config.Args var displayVersion bool var grep string - var pprof int + var pprof string userName := user.Name() flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") @@ -40,7 +39,6 @@ func main() { flag.IntVar(&args.LContext.BeforeContext, "before", 0, "Print lines of leading context before matching lines") flag.IntVar(&args.LContext.MaxCount, "max", 0, "Stop reading file after NUM matching lines") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") - flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") flag.StringVar(&args.LogDir, "logDir", "~/log", "Log dir") @@ -52,6 +50,7 @@ func main() { flag.StringVar(&args.UserName, "user", userName, "Your system user name") flag.StringVar(&args.What, "files", "", "File(s) to read") flag.StringVar(&grep, "grep", "", "Alias for -regex") + flag.StringVar(&pprof, "pprof", "", "Start PProf server this address") flag.Parse() config.Setup(source.Client, &args, flag.Args()) @@ -69,11 +68,9 @@ func main() { args.RegexStr = grep } - if pprof > -1 { - // For debugging purposes only - pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof) - go http.ListenAndServe(pprofArgs, nil) - dlog.Client.Info("Started PProf", pprofArgs) + if pprof != "" { + go http.ListenAndServe(pprof, nil) + dlog.Client.Info("Started PProf", pprof) } client, err := clients.NewGrepClient(args) |
