-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
main.go
49 lines (35 loc) · 1.38 KB
/
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"
"github.com/mariocandela/beelzebub/v3/builder"
"github.com/mariocandela/beelzebub/v3/parser"
log "github.com/sirupsen/logrus"
)
func main() {
var (
quit = make(chan struct{})
configurationsCorePath string
configurationsServicesDirectory string
)
flag.StringVar(&configurationsCorePath, "confCore", "./configurations/beelzebub.yaml", "Provide the path of configurations core")
flag.StringVar(&configurationsServicesDirectory, "confServices", "./configurations/services/", "Directory config services")
flag.Parse()
parser := parser.Init(configurationsCorePath, configurationsServicesDirectory)
coreConfigurations, err := parser.ReadConfigurationsCore()
failOnError(err, "Error during ReadConfigurationsCore: ")
beelzebubServicesConfiguration, err := parser.ReadConfigurationsServices()
failOnError(err, "Error during ReadConfigurationsServices: ")
beelzebubBuilder := builder.NewBuilder()
director := builder.NewDirector(beelzebubBuilder)
beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
failOnError(err, "Error during BuildBeelzebub: ")
err = beelzebubBuilder.Run()
failOnError(err, "Error during run beelzebub core: ")
defer beelzebubBuilder.Close()
<-quit
}
func failOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
}
}