From 2d0539300df1898b2641856e74a1e95760866e81 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 3 Jul 2020 10:10:49 -0400 Subject: [PATCH] Exit if specified config file is not present --- conf/configuration.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/conf/configuration.go b/conf/configuration.go index 7eed7c4cb..a2c5c9faa 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -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() }