Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read toml config from admin app #35

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading