示例#1
0
文件: init.go 项目: hidu/fabio
func initBackend(cfg *config.Config) {
	var err error
	be, err = consul.NewBackend(&cfg.Consul)
	if err != nil {
		log.Fatal("[FATAL] Error initializing backend. ", err)
	}
}
示例#2
0
func initBackend(cfg *config.Config) {
	var err error
	registry.Default, err = consul.NewBackend(&cfg.Consul, cfg.UI.Addr)
	if err != nil {
		log.Fatal("[FATAL] Error initializing backend. ", err)
	}
	if err := registry.Default.Register(); err != nil {
		log.Fatal("[FATAL] Error registering backend. ", err)
	}
}
示例#3
0
文件: main.go 项目: cursesun/fabio
func initBackend(cfg *config.Config) {
	var err error

	switch cfg.Registry.Backend {
	case "file":
		registry.Default, err = file.NewBackend(cfg.Registry.File.Path)
	case "static":
		registry.Default, err = static.NewBackend(cfg.Registry.Static.Routes)
	case "consul":
		registry.Default, err = consul.NewBackend(&cfg.Registry.Consul)
	default:
		log.Fatal("[FATAL] Unknown registry backend ", cfg.Registry.Backend)
	}

	if err != nil {
		log.Fatal("[FATAL] Error initializing backend. ", err)
	}
	if err := registry.Default.Register(); err != nil {
		log.Fatal("[FATAL] Error registering backend. ", err)
	}
}
示例#4
0
文件: main.go 项目: hilerchyn/fabio
// 初始化后端服务器的配置信息
// 初始后端注册服务的默认 registry.Default 注册服务及配置信息
func initBackend(cfg *config.Config) {
	var err error

	// 根据配置中的 Registry -> Backend 的数据(file | static | consul)来判断后端服务的类型,并生成相应的配置信息
	switch cfg.Registry.Backend {
	case "file":
		registry.Default, err = file.NewBackend(cfg.Registry.File.Path)
	case "static":
		registry.Default, err = static.NewBackend(cfg.Registry.Static.Routes)
	case "consul":
		registry.Default, err = consul.NewBackend(&cfg.Registry.Consul)
	default:
		exit.Fatal("[FATAL] Unknown registry backend ", cfg.Registry.Backend)
	}

	if err != nil {
		exit.Fatal("[FATAL] Error initializing backend. ", err)
	}
	if err := registry.Default.Register(); err != nil {
		exit.Fatal("[FATAL] Error registering backend. ", err)
	}
}