Example #1
0
func main() {

	flag.Parse()
	logger.InitLogging(logPath)

	config, err := configuration.LoadFromFile(configFile)

	if err != nil {
		logger.Error.Panicf("Error opening config file : %s", err.Error())
	}

	sane, errors := config.GetCurrentConfiguration().SanityCheckConfiguration(
		&configuration.ConfigContainsRequiredSections{},
		&configuration.CheckForObviousMisConfiguration{})

	if !sane {

		for _, errorAsStr := range errors {
			logger.Error.Print(errorAsStr)
		}

		logger.Error.Panic("Configuration fails checks")
	}

	flipper := NewNoOpFlipper()
	engine := redishappy.NewRedisHappyEngine(flipper, config)
	engine.ConfigureHandlersAndServe(AddHandlers)
}
Example #2
0
func main() {

	flag.Parse()
	logger.InitLogging(logPath)

	config, err := configuration.LoadFromFile(configFile)

	if err != nil {
		logger.Error.Panicf("Error opening config file : %s", err.Error())
	}

	sane, errors := config.GetCurrentConfiguration().SanityCheckConfiguration(
		&configuration.ConfigContainsRequiredSections{},
		&configuration.CheckForObviousMisConfiguration{},
		&HAProxyConfigContainsRequiredSections{},
		&CheckPermissionToWriteToHAProxyConfigFile{},
		&CheckHAProxyTemplateFileExists{},
	)

	if !sane {

		for _, errorAsStr := range errors {
			logger.Error.Print(errorAsStr)
		}

		logger.Error.Panic("Configuration fails checks")
	}

	flipper := NewHAProxyFlipper(config)
	engine := redishappy.NewRedisHappyEngine(flipper, config)

	engine.ConfigureHandlersAndServe(func(mux *web.Mux) {

		templateApi := &TemplateApi{ConfigurationManager: config}
		haProxyApi := &HAProxyApi{ConfigurationManager: config}

		mux.Get("/api/template", templateApi.Get)
		mux.Get("/api/haproxy", haProxyApi.Get)

	})
}