Skip to content

Commit

Permalink
Exit if specified config file is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jul 3, 2020
1 parent f45045d commit 2d05393
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ func InitConfig(cfgFile string) {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
if err := viper.ReadInConfig(); err != nil {
fmt.Println("Navidrome could not open config file: ", err)
os.Exit(1)
}
} else {
// Search config in local directory with name "navidrome" (without extension).
viper.AddConfigPath(".")
viper.SetConfigName("navidrome")
_ = viper.ReadInConfig()
}

_ = viper.BindEnv("port")
viper.SetEnvPrefix("ND")
viper.AutomaticEnv()

_ = viper.ReadInConfig()
}

0 comments on commit 2d05393

Please sign in to comment.