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-08 20:49:53 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-06-26 11:55:49 -05:00
|
|
|
var (
|
|
|
|
quit = make(chan struct{})
|
|
|
|
configurationsCorePath string
|
|
|
|
configurationsServicesDirectory string
|
|
|
|
)
|
2023-06-01 00:15:21 +02:00
|
|
|
|
|
|
|
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()
|
2023-06-26 11:55:49 -05:00
|
|
|
failOnError(err, "Error during ReadConfigurationsCore: ")
|
2022-05-08 20:49:53 +02:00
|
|
|
|
2022-05-12 22:46:15 +02:00
|
|
|
beelzebubServicesConfiguration, err := parser.ReadConfigurationsServices()
|
2023-06-26 11:55:49 -05:00
|
|
|
failOnError(err, "Error during ReadConfigurationsServices: ")
|
2022-05-21 11:43:10 +02:00
|
|
|
|
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-26 11:55:49 -05:00
|
|
|
failOnError(err, "Error during BuildBeelzebub: ")
|
2023-06-01 00:15:21 +02:00
|
|
|
|
|
|
|
err = beelzebubBuilder.Run()
|
2023-06-26 11:55:49 -05:00
|
|
|
failOnError(err, "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)
|
|
|
|
}
|
|
|
|
}
|