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.
		
		
		
		
		
			
		
			
				
					
					
						
							50 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							50 lines
						
					
					
						
							1.0 KiB
						
					
					
				
								package filer
							 | 
						|
								
							 | 
						|
								import (
							 | 
						|
									"os"
							 | 
						|
								
							 | 
						|
									"github.com/chrislusf/seaweedfs/weed/glog"
							 | 
						|
									"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 {
							 | 
						|
												glog.Fatalf("Failed to initialize store for %s: %+v",
							 | 
						|
													store.GetName(), err)
							 | 
						|
											}
							 | 
						|
											f.SetStore(store)
							 | 
						|
											glog.V(0).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 {
							 | 
						|
												glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
							 | 
						|
											}
							 | 
						|
										}
							 | 
						|
									}
							 | 
						|
								}
							 |