summary refs log tree commit diff stats
path: root/svc/conf.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-08 01:04:38 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-08 02:29:33 -0400
commita5a32e7a317dd5cf156e52a71d7be432d0594bf7 (patch)
treec266a1652f78ec446b2eb85f2371e0cfabed65ff /svc/conf.go
parente6beae32cd45ea0057e1a5bc5e4b3f2a098a1a1e (diff)
downloadgetwtxt-a5a32e7a317dd5cf156e52a71d7be432d0594bf7.tar.gz
split db-specific funcs into separate files
Diffstat (limited to 'svc/conf.go')
-rw-r--r--svc/conf.go24
1 files changed, 14 insertions, 10 deletions
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")