-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (54 loc) · 1.45 KB
/
Copy pathmain.go
File metadata and controls
66 lines (54 loc) · 1.45 KB
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
59
60
61
62
63
64
65
66
package main
import (
"context"
"errors"
"flag"
"fmt"
"log"
_ "net/http/pprof"
"os"
"runtime"
"trace-monitor-collector/config"
)
var (
configPathFlag = flag.String("config", "", "path to config file")
version = flag.Bool("version", false, "package version")
IsVerbose = flag.Bool("v", false, "Verbose mode")
IsVeryVerbose = flag.Bool("vv", false, "Very Verbose mode")
IsVeryVeryVerbose = flag.Bool("vvv", false, "Very Very Verbose mode")
AppVersion string = "dev"
)
func main() {
flag.Parse()
if *version {
fmt.Printf("trace-monitor-collector: %s\n", AppVersion)
os.Exit(0)
}
fmt.Printf("Version app: %s\n", AppVersion)
configPath := *configPathFlag
if configPath == "" {
if *IsVerbose || *IsVeryVerbose || *IsVeryVeryVerbose {
log.Println("--config flag is not set, trying to find config.yaml in current folder")
}
configPath = "config.yaml"
}
_, err := os.Stat(configPath)
if errors.Is(err, os.ErrNotExist) {
log.Fatalf("Could not find a config file at \"%s\"", configPath)
}
if err != nil {
log.Fatal(err)
}
cfg, err := config.LoadFromFile(configPath)
if err != nil {
log.Fatal(err)
}
cfg.SetVerbosity(*IsVerbose, *IsVeryVerbose, *IsVeryVeryVerbose)
runtime.SetBlockProfileRate(1)
ctx, _ := context.WithCancel(context.Background())
go handleUdp(ctx, cfg)
go handleFpmStatus(cfg)
go handleHttp(cfg)
go handlePrometheus(cfg)
<-make(chan struct{})
}