2022-05-08 20:49:53 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-11-04 20:06:50 +01:00
|
|
|
"beelzebub/builder"
|
2022-05-08 20:49:53 +02:00
|
|
|
"beelzebub/parser"
|
2023-06-01 00:15:21 +02:00
|
|
|
"flag"
|
2022-05-21 11:43:10 +02:00
|
|
|
"fmt"
|
2023-06-01 00:15:21 +02:00
|
|
|
|
2022-05-08 20:49:53 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var quit = make(chan struct{})
|
|
|
|
|
|
|
|
func main() {
|
2023-06-01 00:15:21 +02:00
|
|
|
var configurationsCorePath string
|
|
|
|
var 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)
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-05-12 22:46:15 +02:00
|
|
|
coreConfigurations, err := parser.ReadConfigurationsCore()
|
2022-06-04 17:34:03 +02:00
|
|
|
failOnError(err, fmt.Sprintf("Error during ReadConfigurationsCore: "))
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-05-12 22:46:15 +02:00
|
|
|
beelzebubServicesConfiguration, err := parser.ReadConfigurationsServices()
|
2022-05-21 11:43:10 +02:00
|
|
|
failOnError(err, fmt.Sprintf("Error during ReadConfigurationsServices: "))
|
|
|
|
|
2022-11-04 20:06:50 +01:00
|
|
|
beelzebubBuilder := builder.NewBuilder()
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-11-04 20:06:50 +01:00
|
|
|
director := builder.NewDirector(beelzebubBuilder)
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-11-04 20:06:50 +01:00
|
|
|
beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
|
2023-06-01 00:15:21 +02:00
|
|
|
failOnError(err, fmt.Sprintf("Error during BuildBeelzebub: "))
|
|
|
|
|
|
|
|
err = beelzebubBuilder.Run()
|
|
|
|
failOnError(err, fmt.Sprintf("Error during run beelzebub core: "))
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-11-04 20:06:50 +01:00
|
|
|
defer beelzebubBuilder.Close()
|
|
|
|
|
2022-05-08 20:49:53 +02:00
|
|
|
<-quit
|
|
|
|
}
|
2022-05-21 11:43:10 +02:00
|
|
|
|
|
|
|
func failOnError(err error, msg string) {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("%s: %s", msg, err)
|
|
|
|
}
|
|
|
|
}
|