mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
6c9156b25f
losing filename and line number. Critical for debugging.
51 lines
1 KiB
Go
51 lines
1 KiB
Go
package filer
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/util/log"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var (
|
|
Stores []FilerStore
|
|
)
|
|
|
|
func (f *Filer) LoadConfiguration(config *viper.Viper) {
|
|
|
|
validateOneEnabledStore(config)
|
|
|
|
for _, store := range Stores {
|
|
if config.GetBool(store.GetName() + ".enabled") {
|
|
if err := store.Initialize(config, store.GetName()+"."); err != nil {
|
|
log.Fatalf("Failed to initialize store for %s: %+v",
|
|
store.GetName(), err)
|
|
}
|
|
f.SetStore(store)
|
|
log.Infof("Configure filer for %s", store.GetName())
|
|
return
|
|
}
|
|
}
|
|
|
|
println()
|
|
println("Supported filer stores are:")
|
|
for _, store := range Stores {
|
|
println(" " + store.GetName())
|
|
}
|
|
|
|
os.Exit(-1)
|
|
}
|
|
|
|
func validateOneEnabledStore(config *viper.Viper) {
|
|
enabledStore := ""
|
|
for _, store := range Stores {
|
|
if config.GetBool(store.GetName() + ".enabled") {
|
|
if enabledStore == "" {
|
|
enabledStore = store.GetName()
|
|
} else {
|
|
log.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
|
|
}
|
|
}
|
|
}
|
|
}
|