diff options
| -rw-r--r-- | TODO.md | 3 | ||||
| -rw-r--r-- | cmd/dcat/main.go | 13 | ||||
| -rw-r--r-- | cmd/dgrep/main.go | 13 | ||||
| -rw-r--r-- | cmd/dmap/main.go | 12 | ||||
| -rw-r--r-- | cmd/dserver/main.go | 13 | ||||
| -rw-r--r-- | cmd/dtail/main.go | 12 | ||||
| -rw-r--r-- | cmd/dtailhealth/main.go | 13 | ||||
| -rw-r--r-- | integrationtests/dmap_test.go | 2 |
8 files changed, 38 insertions, 43 deletions
@@ -13,9 +13,6 @@ This is a loose list of what to do. Maybe for the next releae or maybe for a lat [ ] Document color configuratio [ ] Go through the git history and document more stuff [ ] Manual test/adjust dtail colors -[ ] More integration test colors (via dcat?) [ ] Integration test for dtail in serverless mode -[x] Integration test for dtail normal mode [ ] Document how to run ingeration tests [ ] dserver scheduled queries integration test -[ ] fix scheduled queries JSON schema 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) 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) diff --git a/cmd/dmap/main.go b/cmd/dmap/main.go index 7591c6c..2c941f3 100644 --- a/cmd/dmap/main.go +++ b/cmd/dmap/main.go @@ -6,6 +6,10 @@ import ( "os" "sync" + "net/http" + _ "net/http" + _ "net/http/pprof" + "github.com/mimecast/dtail/internal/clients" "github.com/mimecast/dtail/internal/config" "github.com/mimecast/dtail/internal/io/dlog" @@ -19,6 +23,8 @@ import ( // The evil begins here. func main() { var displayVersion bool + var pprof string + args := config.Args{ Mode: omode.MapClient, } @@ -43,6 +49,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()) @@ -56,6 +63,11 @@ func main() { wg.Add(1) dlog.Start(ctx, &wg, source.Client) + if pprof != "" { + go http.ListenAndServe(pprof, nil) + dlog.Client.Info("Started PProf", pprof) + } + client, err := clients.NewMaprClient(args, clients.DefaultMode) if err != nil { dlog.Client.FatalPanic(err) diff --git a/cmd/dserver/main.go b/cmd/dserver/main.go index 81e04e9..24143eb 100644 --- a/cmd/dserver/main.go +++ b/cmd/dserver/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "net/http" _ "net/http" _ "net/http/pprof" @@ -26,7 +25,7 @@ func main() { var args config.Args var color bool var displayVersion bool - var pprof int + var pprof string var shutdownAfter int user.NoRootCheck() @@ -36,13 +35,13 @@ func main() { "Enable relaxced SSH auth mode (don't use in production!)") flag.BoolVar(&displayVersion, "version", false, "Display version") flag.IntVar(&args.SSHPort, "port", config.DefaultSSHPort, "SSH server port") - flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.IntVar(&shutdownAfter, "shutdownAfter", 0, "Shutdown after so many seconds") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.LogDir, "logDir", "", "Log dir") flag.StringVar(&args.LogLevel, "logLevel", config.DefaultLogLevel, "Log level") flag.StringVar(&args.Logger, "logger", config.DefaultServerLogger, "Logger name") flag.StringVar(&args.SSHBindAddress, "bindAddress", "", "The SSH bind address") + flag.StringVar(&pprof, "pprof", "", "Start PProf server this address") flag.Parse() args.NoColor = !color @@ -77,11 +76,9 @@ func main() { dlog.Server.Fatal("SSH relaxed-auth mode enabled") } - if pprof > -1 { - // Start of pprof server for development purposes only. - pprofArgs := fmt.Sprintf("0.0.0.0:%d", pprof) - dlog.Server.Info("Starting PProf", pprofArgs) - go http.ListenAndServe(pprofArgs, nil) + if pprof != "" { + dlog.Server.Info("Starting PProf", pprof) + go http.ListenAndServe(pprof, nil) } serv := server.New() diff --git a/cmd/dtail/main.go b/cmd/dtail/main.go index 54800b6..ff0cea9 100644 --- a/cmd/dtail/main.go +++ b/cmd/dtail/main.go @@ -30,7 +30,7 @@ func main() { var displayWideColorTable bool var displayVersion bool var grep string - var pprof int + var pprof string var shutdownAfter int userName := user.Name() @@ -51,7 +51,6 @@ func main() { 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(&args.Timeout, "timeout", 0, "Max time dtail server will collect data until disconnection") - flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.IntVar(&shutdownAfter, "shutdownAfter", 3600*24, "Shutdown after so many seconds") flag.StringVar(&args.ConfigFile, "cfg", "", "Config file path") flag.StringVar(&args.Discovery, "discovery", "", "Server discovery method") @@ -65,6 +64,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() if grep != "" { @@ -101,11 +101,9 @@ func main() { os.Exit(1) } - 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) } var client clients.Client diff --git a/cmd/dtailhealth/main.go b/cmd/dtailhealth/main.go index ec97d3a..326c43a 100644 --- a/cmd/dtailhealth/main.go +++ b/cmd/dtailhealth/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "os" "sync" @@ -23,13 +22,13 @@ import ( func main() { var args config.Args var displayVersion bool - var pprof int + var pprof string flag.BoolVar(&displayVersion, "version", false, "Display version") - flag.IntVar(&pprof, "pprof", -1, "Start PProf server this port") flag.StringVar(&args.Logger, "logger", config.DefaultHealthCheckLogger, "Logger name") flag.StringVar(&args.LogLevel, "logLevel", "none", "Log level") flag.StringVar(&args.ServersStr, "server", "", "Remote server to connect") + flag.StringVar(&pprof, "pprof", "", "Start PProf server this address") flag.Parse() if displayVersion { @@ -44,11 +43,9 @@ func main() { wg.Add(1) dlog.Start(ctx, &wg, source.HealthCheck) - 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) } healthClient, _ := clients.NewHealthClient(args) diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go index b3c048a..350ac6a 100644 --- a/integrationtests/dmap_test.go +++ b/integrationtests/dmap_test.go @@ -102,7 +102,7 @@ func TestDMap3(t *testing.T) { // Read many input files at once. args := []string{"--logLevel", "trace", "--query", query} - for i := 0; i < 1; i++ { + for i := 0; i < 100; i++ { args = append(args, inFile) } |
