Example #1
0
func read_cfg(cfg_path string) *Config {
	config := new(Config)
	app_cfg := make(map[string]string)
	err := cfg.Load(cfg_path, app_cfg)
	if err != nil {
		log.Fatal(err)
	}

	config.port = get_int(app_cfg, "port")
	config.http_listen_address = get_string(app_cfg, "http_listen_address")
	config.redis_address = get_string(app_cfg, "redis_address")
	config.mysqldb_datasource = get_string(app_cfg, "mysqldb_source")
	config.mysqldb_appdatasource = get_opt_string(app_cfg, "mysqldb_appsource")
	config.socket_io_address = get_string(app_cfg, "socket_io_address")

	str := get_string(app_cfg, "storage_pool")
	array := strings.Split(str, " ")
	config.storage_addrs = array
	if len(config.storage_addrs) == 0 {
		log.Fatal("storage pool config")
	}

	str = get_string(app_cfg, "route_pool")
	array = strings.Split(str, " ")
	config.route_addrs = array
	if len(config.route_addrs) == 0 {
		log.Fatal("route pool config")
	}

	return config
}
Example #2
0
func read_cfg(path string) {
	app_cfg := make(map[string]string)
	err := cfg.Load(path, app_cfg)
	if err != nil {
		log.Fatal(err)
	}
	root, present := app_cfg["root"]
	if !present {
		log.Info("need config root directory")
		os.Exit(1)
	}
	ROOT = root

	port, present := app_cfg["port"]
	if !present {
		log.Info("need config listen port")
		os.Exit(1)
	}
	nport, err := strconv.Atoi(port)
	if err != nil {
		log.Info("need config listen port")
		os.Exit(1)
	}
	PORT = nport
	if _, present = app_cfg["bind_addr"]; present {
		BIND_ADDR = app_cfg["bind_addr"]
	}
	log.Info("root:%s bind addr:%s port:%d\n", ROOT, BIND_ADDR, PORT)
}
Example #3
0
func read_route_cfg(cfg_path string) *RouteConfig {
	config := new(RouteConfig)
	app_cfg := make(map[string]string)
	err := cfg.Load(cfg_path, app_cfg)
	if err != nil {
		log.Fatal(err)
	}

	config.listen = get_string(app_cfg, "listen")
	config.redis_address = get_string(app_cfg, "redis_address")
	return config
}
Example #4
0
func read_storage_cfg(cfg_path string) *StorageConfig {
	config := new(StorageConfig)
	app_cfg := make(map[string]string)
	err := cfg.Load(cfg_path, app_cfg)
	if err != nil {
		log.Fatal(err)
	}

	config.listen = get_string(app_cfg, "listen")
	config.storage_root = get_string(app_cfg, "storage_root")
	config.redis_address = get_string(app_cfg, "redis_address")
	config.mysqldb_datasource = get_string(app_cfg, "mysqldb_source")
	config.sync_listen = get_string(app_cfg, "sync_listen")
	config.master_address = get_opt_string(app_cfg, "master_address")
	return config
}