1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
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.BoolVar(&args.NoAuthKey, "no-auth-key", false, "Disable auth-key fast reconnect feature")
flag.StringVar(&pprof, "pprof", "", "Start PProf server this address")
flag.Parse()
if displayVersion {
version.PrintAndExit(false)
}
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 != "" {
dlog.Client.Info("Starting PProf", pprof)
go func() {
if err := http.ListenAndServe(pprof, nil); err != nil {
dlog.Client.Error("PProf server exited", err)
}
}()
}
healthClient, _ := clients.NewHealthClient(args)
os.Exit(healthClient.Start(ctx, signal.NoCh(ctx)))
}
|