Skip to content

Commit

Permalink
Abort startup if config file is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jul 21, 2021
1 parent eeb14f0 commit 4f9d546
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func LoadFromFile(confFile string) {
func Load() {
err := viper.Unmarshal(&Server)
if err != nil {
fmt.Println("Error parsing config:", err)
fmt.Println("FATAL: Error parsing config:", err)
os.Exit(1)
}
err = os.MkdirAll(Server.DataFolder, os.ModePerm)
if err != nil {
fmt.Println("Error creating data path:", "path", Server.DataFolder, err)
fmt.Println("FATAL: Error creating data path:", "path", Server.DataFolder, err)
os.Exit(1)
}
Server.ConfigFile = viper.GetViper().ConfigFileUsed()
Expand Down Expand Up @@ -254,8 +254,8 @@ func InitConfig(cfgFile string) {
viper.AutomaticEnv()

err := viper.ReadInConfig()
if cfgFile != "" && err != nil {
fmt.Println("Navidrome could not open config file: ", err)
if viper.ConfigFileUsed() != "" && err != nil {
fmt.Println("FATAL: Navidrome could not open config file: ", err)
os.Exit(1)
}
}
Expand Down

0 comments on commit 4f9d546

Please sign in to comment.