From 06ece112c0dd20c0c211c538216fe64ebe4045c9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 14 Oct 2021 20:10:55 +0300 Subject: add dgrep context integration tests --- cmd/dgrep/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cmd') diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go index 2d7e53b..3cbb3cc 100644 --- a/cmd/dgrep/main.go +++ b/cmd/dgrep/main.go @@ -3,9 +3,14 @@ package main import ( "context" "flag" + "fmt" "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" @@ -20,6 +25,7 @@ func main() { var args config.Args var displayVersion bool var grep string + var pprof int userName := user.Name() flag.BoolVar(&args.NoColor, "noColor", false, "Disable ANSII terminal colors") @@ -34,6 +40,7 @@ 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") @@ -65,6 +72,13 @@ 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) + } + client, err := clients.NewGrepClient(args) if err != nil { panic(err) -- cgit v1.2.3