fix: clarify which config file is used on startup

This commit is contained in:
kolaente 2022-02-19 11:31:23 +01:00
parent 2bc82bc1a0
commit 44aaf0a4ec
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -355,12 +355,6 @@ func InitConfig() {
viper.AddConfigPath(".")
viper.SetConfigName("config")
err = viper.ReadInConfig()
if err != nil {
log.Println(err.Error())
log.Println("Using default config.")
return
}
if CacheType.GetString() == "keyvalue" {
CacheType.Set(KeyvalueType.GetString())
@ -395,7 +389,18 @@ func InitConfig() {
MetricsEnabled.Set(true)
}
log.Printf("Using config file: %s", viper.ConfigFileUsed())
if viper.ConfigFileUsed() != "" {
log.Printf("Using config file: %s", viper.ConfigFileUsed())
err = viper.ReadInConfig()
if err != nil {
log.Println(err.Error())
log.Println("Using default config.")
return
}
} else {
log.Println("No config file found, using default or config from environment variables.")
}
}
func random(length int) (string, error) {