Backend: Refactor config initialization

Signed-off-by: Michael Mayer <michael@lastzero.net>
This commit is contained in:
Michael Mayer
2020-10-08 08:52:03 +02:00
parent 27dff245a5
commit 5fa47652ee
24 changed files with 130 additions and 113 deletions

View File

@@ -45,10 +45,6 @@ func startAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
if err := conf.CreateDirectories(); err != nil {
return err
}
if ctx.IsSet("config") {
fmt.Printf("NAME VALUE\n")
fmt.Printf("detach-server %t\n", conf.DetachServer())
@@ -60,18 +56,14 @@ func startAction(ctx *cli.Context) error {
return nil
}
// pass this context down the chain
cctx, cancel := context.WithCancel(context.Background())
if conf.HttpServerPort() < 1 || conf.HttpServerPort() > 65535 {
log.Fatal("server port must be a number between 1 and 65535")
}
if err := conf.CreateDirectories(); err != nil {
log.Fatal(err)
}
// pass this context down the chain
cctx, cancel := context.WithCancel(context.Background())
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
log.Fatal(err)
}