summaryrefslogtreecommitdiff
path: root/cmd/dtailhealth
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-14 20:55:35 +0300
committerPaul Buetow <paul@buetow.org>2021-10-15 08:40:54 +0300
commit698fb76b98c46c677abe13fdc93afc6c4f38c39e (patch)
treeac6884ea24d262c36d1f3b6e12a6adf2ba7acb8b /cmd/dtailhealth
parent06ece112c0dd20c0c211c538216fe64ebe4045c9 (diff)
refactor
Diffstat (limited to 'cmd/dtailhealth')
-rw-r--r--cmd/dtailhealth/main.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/cmd/dtailhealth/main.go b/cmd/dtailhealth/main.go
new file mode 100644
index 0000000..7e54b1c
--- /dev/null
+++ b/cmd/dtailhealth/main.go
@@ -0,0 +1,49 @@
+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"
+ "github.com/mimecast/dtail/internal/io/signal"
+ "github.com/mimecast/dtail/internal/source"
+)
+
+// The evil begins here.
+func main() {
+ var args config.Args
+ var pprof int
+
+ 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.Parse()
+
+ config.Setup(source.HealthCheck, &args, flag.Args())
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ var wg sync.WaitGroup
+ 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)
+ }
+
+ healthClient, _ := clients.NewHealthClient(args)
+ os.Exit(healthClient.Start(ctx, signal.NoCh(ctx)))
+}