Skip to content

Commit

Permalink
Read toml config from admin app (#35)
Browse files Browse the repository at this point in the history
Read the toml config from the admin app too
  • Loading branch information
matheusgomes28 authored Feb 25, 2024
1 parent 371a110 commit 4e09929
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions cmd/urchin-admin/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"os"

Expand All @@ -12,15 +13,30 @@ import (
)

func main() {

// sets zerolog as the main logger
// in this APP
common.SetupLogger()

app_settings, err := common.LoadSettings()
if err != nil {
log.Fatal().Msgf("could not load app settings: %v", err)
os.Exit(-1)
config_toml := flag.String("config", "", "path to config toml file")
flag.Parse()

var app_settings common.AppSettings
if *config_toml != "" {
log.Info().Msgf("reading config file %s", *config_toml)
settings, err := common.ReadConfigToml(*config_toml)
if err != nil {
log.Error().Msgf("could not read toml: %v", err)
os.Exit(-2)
}
app_settings = settings
} else {
log.Info().Msgf("no config passed, reading environment variable settings")
settings, err := common.LoadSettings()
if err != nil {
log.Fatal().Msgf("could not load app settings: %v", err)
os.Exit(-1)
}
app_settings = settings
}

database, err := database.MakeSqlConnection(
Expand Down

0 comments on commit 4e09929

Please sign in to comment.