예제 #1
0
func TestConfigLoader(t *testing.T) {
	setupTest()
	defer cleanup()
	//Set some config items
	config.Notifications.FromEmail = "*****@*****.**"
	//Put them in Etcd
	config_loader.SetConfig()
	//Reset the local config to defaults
	config.LoadDefaults()
	//Check the config items we set
	if config.Notifications.FromEmail != "*****@*****.**" {
		t.Errorf("Notifications.FromEmail not set: %v", config.Notifications.FromEmail)
	}
}
예제 #2
0
파일: main.go 프로젝트: rhinoman/wikifeat
func main() {
	// Get command line arguments
	configFile := parseCmdParams()
	// Load Configuration
	config.LoadConfig(configFile)
	// Set up Logger
	log.SetOutput(&lumberjack.Logger{
		Filename:   config.Logger.LogFile,
		MaxSize:    config.Logger.MaxSize,
		MaxBackups: config.Logger.MaxBackups,
		MaxAge:     config.Logger.MaxAge,
	})
	// Initialize our etcd and couchdb connections
	config_loader.InitRegistry()
	config_loader.InitDatabase()
	// Clear out any old config that may be hanging around
	config_loader.ClearConfig()
	// Set the configuration keys in etcd
	config_loader.SetConfig()
	//Start up the config service
	wsContainer := restful.NewContainer()
	wsContainer.Router(restful.CurlyRouter{})
	//Enable GZIP support
	wsContainer.EnableContentEncoding(true)
	cc := config_service.ConfigController{}
	cc.Register(wsContainer)
	registry.Init("Config", registry.ConfigServiceLocation)
	httpAddr := ":" + config.Service.Port
	if config.Service.UseSSL == true {
		certFile := config.Service.SSLCertFile
		keyFile := config.Service.SSLKeyFile
		log.Fatal(http.ListenAndServeTLS(httpAddr,
			certFile, keyFile, wsContainer))
	} else {
		log.Fatal(http.ListenAndServe(httpAddr, wsContainer))
	}
}