avoid unnecessary fail fast
fix https://github.com/seaweedfs/seaweedfs/issues/7417
This commit is contained in:
@@ -52,16 +52,20 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
|||||||
if strings.Contains(err.Error(), "Not Found") {
|
if strings.Contains(err.Error(), "Not Found") {
|
||||||
glog.V(1).Infof("Reading %s: %v", viper.ConfigFileUsed(), err)
|
glog.V(1).Infof("Reading %s: %v", viper.ConfigFileUsed(), err)
|
||||||
} else {
|
} else {
|
||||||
glog.Fatalf("Reading %s: %v", viper.ConfigFileUsed(), err)
|
// If the config is required, fail immediately
|
||||||
|
if required {
|
||||||
|
glog.Fatalf("Reading %s: %v", viper.ConfigFileUsed(), err)
|
||||||
|
}
|
||||||
|
// If the config is optional, log a warning but don't crash
|
||||||
|
glog.Warningf("Reading %s: %v. Skipping optional configuration.", viper.ConfigFileUsed(), err)
|
||||||
}
|
}
|
||||||
if required {
|
if required {
|
||||||
glog.Fatalf("Failed to load %s.toml file from current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/"+
|
glog.Fatalf("Failed to load %s.toml file from current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/"+
|
||||||
"\n\nPlease use this command to generate the default %s.toml file\n"+
|
"\n\nPlease use this command to generate the default %s.toml file\n"+
|
||||||
" weed scaffold -config=%s -output=.\n\n\n",
|
" weed scaffold -config=%s -output=.\n\n\n",
|
||||||
configFileName, configFileName, configFileName)
|
configFileName, configFileName, configFileName)
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
glog.V(1).Infof("Reading %s.toml from %s", configFileName, viper.ConfigFileUsed())
|
glog.V(1).Infof("Reading %s.toml from %s", configFileName, viper.ConfigFileUsed())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user