mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
Abort startup if config file is invalid
This commit is contained in:
parent
eeb14f0243
commit
4f9d546da4
1 changed files with 4 additions and 4 deletions
|
@ -103,12 +103,12 @@ func LoadFromFile(confFile string) {
|
||||||
func Load() {
|
func Load() {
|
||||||
err := viper.Unmarshal(&Server)
|
err := viper.Unmarshal(&Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error parsing config:", err)
|
fmt.Println("FATAL: Error parsing config:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(Server.DataFolder, os.ModePerm)
|
err = os.MkdirAll(Server.DataFolder, os.ModePerm)
|
||||||
if err != nil {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
Server.ConfigFile = viper.GetViper().ConfigFileUsed()
|
Server.ConfigFile = viper.GetViper().ConfigFileUsed()
|
||||||
|
@ -254,8 +254,8 @@ func InitConfig(cfgFile string) {
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
if cfgFile != "" && err != nil {
|
if viper.ConfigFileUsed() != "" && err != nil {
|
||||||
fmt.Println("Navidrome could not open config file: ", err)
|
fmt.Println("FATAL: Navidrome could not open config file: ", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue