You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.0 KiB

6 years ago
6 years ago
6 years ago
  1. package filer2
  2. import (
  3. "os"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/spf13/viper"
  6. )
  7. var (
  8. Stores []FilerStore
  9. )
  10. func (f *Filer) LoadConfiguration(config *viper.Viper) {
  11. validateOneEnabledStore(config)
  12. for _, store := range Stores {
  13. if config.GetBool(store.GetName() + ".enabled") {
  14. viperSub := config.Sub(store.GetName())
  15. if err := store.Initialize(viperSub); err != nil {
  16. glog.Fatalf("Failed to initialize store for %s: %+v",
  17. store.GetName(), err)
  18. }
  19. f.SetStore(store)
  20. glog.V(0).Infof("Configure filer for %s", store.GetName())
  21. return
  22. }
  23. }
  24. println()
  25. println("Supported filer stores are:")
  26. for _, store := range Stores {
  27. println(" " + store.GetName())
  28. }
  29. os.Exit(-1)
  30. }
  31. func validateOneEnabledStore(config *viper.Viper) {
  32. enabledStore := ""
  33. for _, store := range Stores {
  34. if config.GetBool(store.GetName() + ".enabled") {
  35. if enabledStore == "" {
  36. enabledStore = store.GetName()
  37. } else {
  38. glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
  39. }
  40. }
  41. }
  42. }