Clean up a bit
This commit is contained in:
@@ -88,18 +88,19 @@ func InitConfig(cfgFile string) {
|
|||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
// Use config file from the flag.
|
// Use config file from the flag.
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
|
||||||
fmt.Println("Navidrome could not open config file: ", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Search config in local directory with name "navidrome" (without extension).
|
// Search config in local directory with name "navidrome" (without extension).
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
viper.SetConfigName("navidrome")
|
viper.SetConfigName("navidrome")
|
||||||
_ = viper.ReadInConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = viper.BindEnv("port")
|
_ = viper.BindEnv("port")
|
||||||
viper.SetEnvPrefix("ND")
|
viper.SetEnvPrefix("ND")
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if cfgFile != "" && err != nil {
|
||||||
|
fmt.Println("Navidrome could not open config file: ", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user