From a5a32e7a317dd5cf156e52a71d7be432d0594bf7 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sat, 8 Jun 2019 01:04:38 -0400 Subject: split db-specific funcs into separate files --- svc/conf.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'svc/conf.go') diff --git a/svc/conf.go b/svc/conf.go index 0aaee14..9099477 100644 --- a/svc/conf.go +++ b/svc/conf.go @@ -135,22 +135,19 @@ func initConfig() { confObj.Port = viper.GetInt("ListenPort") confObj.LogFile = viper.GetString("LogFile") - if *flagDBType == "" { - confObj.DBType = strings.ToLower(viper.GetString("DatabaseType")) - } else { + confObj.DBType = strings.ToLower(viper.GetString("DatabaseType")) + if *flagDBType != "" { confObj.DBType = *flagDBType } - if *flagDBPath == "" { - confObj.DBPath = viper.GetString("DatabasePath") - } else { + confObj.DBPath = viper.GetString("DatabasePath") + if *flagDBPath != "" { confObj.DBPath = *flagDBPath } log.Printf("Using %v database: %v\n", confObj.DBType, confObj.DBPath) - if *flagAssets == "" { - confObj.AssetsDir = viper.GetString("AssetsDirectory") - } else { + confObj.AssetsDir = viper.GetString("AssetsDirectory") + if *flagAssets != "" { confObj.AssetsDir = *flagAssets } @@ -192,9 +189,16 @@ func rebindConfig() { confObj.Mu.Lock() - confObj.LogFile = viper.GetString("LogFile") confObj.DBType = strings.ToLower(viper.GetString("DatabaseType")) + if *flagDBType != "" { + confObj.DBType = *flagDBType + } + + confObj.LogFile = viper.GetString("LogFile") confObj.DBPath = viper.GetString("DatabasePath") + if *flagDBPath != "" { + confObj.DBPath = *flagDBPath + } confObj.StdoutLogging = viper.GetBool("StdoutLogging") confObj.CacheInterval = viper.GetDuration("StatusFetchInterval") confObj.DBInterval = viper.GetDuration("DatabasePushInterval") -- cgit 1.4.1-2-gfad0