-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
49 lines (40 loc) · 985 Bytes
/
main.go
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
package main
import (
"flag"
"os"
"github.com/criteo/traffic-mirroring/mirror/config"
_ "github.com/criteo/traffic-mirroring/mirror/modules/control"
_ "github.com/criteo/traffic-mirroring/mirror/modules/sink"
_ "github.com/criteo/traffic-mirroring/mirror/modules/source"
"github.com/criteo/traffic-mirroring/mirror/server"
log "github.com/sirupsen/logrus"
)
func main() {
cfgPath := flag.String("c", "config.json", "Config file path")
logLevel := flag.String("log-level", "info", "Log level")
flag.Parse()
l, err := log.ParseLevel(*logLevel)
if err != nil {
log.Fatal(err)
}
log.SetLevel(l)
f, err := os.Open(*cfgPath)
if err != nil {
log.Fatalf("cannot open config file: %s", err)
}
cfg, err := config.Create(f)
if err != nil {
log.Fatal(err)
}
if cfg.ListenAddr != "" {
srv := server.New(cfg.ListenAddr, cfg.Pipeline)
go func() {
err := srv.Run()
if err != nil {
log.Error(err)
}
}()
}
for range cfg.Pipeline.Output() {
}
}