diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-21 21:28:49 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-21 21:28:49 +0300 |
| commit | f4207a55f71bfbcfdc532d5cdd3befaa3474a157 (patch) | |
| tree | ea5e4a2d2a67035f645bdee496ae55a52034178a /cmd/dtailhealth | |
| parent | d80d6070557e3a800e3a54967af9eced518f116b (diff) | |
| parent | 739205206d63bf42f4e843b39d04d4c8cd8207c3 (diff) | |
merge develop
Diffstat (limited to 'cmd/dtailhealth')
| -rw-r--r-- | cmd/dtailhealth/main.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cmd/dtailhealth/main.go b/cmd/dtailhealth/main.go new file mode 100644 index 0000000..326c43a --- /dev/null +++ b/cmd/dtailhealth/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "context" + "flag" + "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" + "github.com/mimecast/dtail/internal/version" +) + +// The evil begins here. +func main() { + var args config.Args + var displayVersion bool + var pprof string + + flag.BoolVar(&displayVersion, "version", false, "Display version") + 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 { + version.PrintAndExit() + } + + 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 != "" { + go http.ListenAndServe(pprof, nil) + dlog.Client.Info("Started PProf", pprof) + } + + healthClient, _ := clients.NewHealthClient(args) + os.Exit(healthClient.Start(ctx, signal.NoCh(ctx))) +} |
