From b679462fa687b375ccefd3c11fec3fd96b9b4d60 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 20 Oct 2021 06:41:08 +0300 Subject: make pprof bind address configurable --- cmd/dcat/main.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'cmd/dcat') diff --git a/cmd/dcat/main.go b/cmd/dcat/main.go index 5e35d6f..5fd22ea 100644 --- a/cmd/dcat/main.go +++ b/cmd/dcat/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "os" "sync" @@ -24,7 +23,7 @@ import ( func main() { var args config.Args var displayVersion bool - var pprof int + var pprof string userName := user.Name() @@ -36,7 +35,6 @@ func main() { flag.IntVar(&args.ConnectionsPerCPU, "cpc", config.DefaultConnectionsPerCPU, "How many connections established per CPU core concurrently") 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") @@ -46,6 +44,7 @@ func main() { flag.StringVar(&args.ServersStr, "servers", "", "Remote servers to connect") flag.StringVar(&args.UserName, "user", userName, "Your system user name") flag.StringVar(&args.What, "files", "", "File(s) to read") + flag.StringVar(&pprof, "pprof", "", "Start PProf server this address") flag.Parse() config.Setup(source.Client, &args, flag.Args()) @@ -59,11 +58,9 @@ func main() { wg.Add(1) dlog.Start(ctx, &wg, source.Client) - 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.NewCatClient(args) -- cgit v1.2.3