aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/configuration.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer2/configuration.go')
-rw-r--r--weed/filer2/configuration.go36
1 files changed, 5 insertions, 31 deletions
diff --git a/weed/filer2/configuration.go b/weed/filer2/configuration.go
index dac537673..387672311 100644
--- a/weed/filer2/configuration.go
+++ b/weed/filer2/configuration.go
@@ -4,7 +4,7 @@ import (
"os"
"github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/spf13/viper"
+ "github.com/spf13/viper"
)
const (
@@ -91,29 +91,17 @@ var (
Stores []FilerStore
)
-func (f *Filer) LoadConfiguration() {
-
- // find a filer store
- viper.SetConfigName("filer") // name of config file (without extension)
- viper.AddConfigPath(".") // optionally look for config in the working directory
- viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
- viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
- if err := viper.ReadInConfig(); err != nil { // Handle errors reading the config file
- glog.Fatalf("Failed to load filer.toml file from current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/" +
- "\n\nPlease follow this example and add a filer.toml file to " +
- "current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/:\n" + FILER_TOML_EXAMPLE)
- }
+func (f *Filer) LoadConfiguration(config *viper.Viper) {
- glog.V(0).Infof("Reading filer configuration from %s", viper.ConfigFileUsed())
for _, store := range Stores {
- if viper.GetBool(store.GetName() + ".enabled") {
- viperSub := viper.Sub(store.GetName())
+ if config.GetBool(store.GetName() + ".enabled") {
+ viperSub := config.Sub(store.GetName())
if err := store.Initialize(viperSub); err != nil {
glog.Fatalf("Failed to initialize store for %s: %+v",
store.GetName(), err)
}
f.SetStore(store)
- glog.V(0).Infof("Configure filer for %s from %s", store.GetName(), viper.ConfigFileUsed())
+ glog.V(0).Infof("Configure filer for %s", store.GetName())
return
}
}
@@ -124,19 +112,5 @@ func (f *Filer) LoadConfiguration() {
println(" " + store.GetName())
}
- println()
- println("Please configure a supported filer store in", viper.ConfigFileUsed())
- println()
-
os.Exit(-1)
}
-
-// A simplified interface to decouple from Viper
-type Configuration interface {
- GetString(key string) string
- GetBool(key string) bool
- GetInt(key string) int
- GetInt64(key string) int64
- GetFloat64(key string) float64
- GetStringSlice(key string) []string
-}