summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-14 20:10:55 +0300
committerPaul Buetow <paul@buetow.org>2021-10-14 20:11:23 +0300
commit06ece112c0dd20c0c211c538216fe64ebe4045c9 (patch)
tree98f290d8642b59087a03938b04052e056912b44d /cmd
parent6075b52103c7d42a7c4dc91bde9e64b2f92281de (diff)
add dgrep context integration tests
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dgrep/main.go14
1 files changed, 14 insertions, 0 deletions
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)