Пример #1
0
func init() {
	// 设置日志文件的存储目录
	logUtil.SetLogPath(filepath.Join(fileUtil.GetCurrentPath(), "LOG"))

	var err error

	// 读取配置文件内容
	config, err := configUtil.ReadJsonConfig(CONFIG_FILE_NAME)
	checkError(err)

	ServerGroupId, err = configUtil.ReadIntJsonValue(config, "ServerGroupId")
	checkError(err)
	ServerActivateUrl, err = configUtil.ReadStringJsonValue(config, "ServerActivateUrl")
	checkError(err)
	GameDBConnection, err = configUtil.ReadStringJsonValue(config, "GameDBConnection")
	checkError(err)
	GameModelDBConnection, err = configUtil.ReadStringJsonValue(config, "GameModelDBConnection")
	checkError(err)
	DEBUG, err = configUtil.ReadBoolJsonValue(config, "DEBUG")
	checkError(err)

	// 激活服务器
	err = manageUtil.ActivateServer(ServerActivateUrl, ServerGroupId)
	if err != nil {
		checkError(fmt.Errorf("激活服务器失败,错误信息为:", err))
	}

	DBConnectionString = manageUtil.GetDBConnectionString()
}
Пример #2
0
func init() {
	var err error

	// 读取配置文件内容
	config, err := configUtil.ReadJsonConfig(CONFIG_FILE_NAME)
	checkError(err)

	// 解析ServerGroupId
	ServerGroupId, err = configUtil.ReadIntJsonValue(config, "ServerGroupId")
	checkError(err)

	// 解析ChatDBConnection配置
	ChatDBConnection, err = configUtil.ReadStringJsonValue(config, "ChatDBConnection")
	checkError(err)
	ChatDBMaxOpenConns, err = configUtil.ReadIntJsonValue(config, "ChatDBMaxOpenConns")
	checkError(err)
	ChatDBMaxIdleConns, err = configUtil.ReadIntJsonValue(config, "ChatDBMaxIdleConns")
	checkError(err)

	// 解析ModelDBConnection配置
	ModelDBConnection, err = configUtil.ReadStringJsonValue(config, "ModelDBConnection")
	checkError(err)
	ModelDBMaxOpenConns, err = configUtil.ReadIntJsonValue(config, "ModelDBMaxOpenConns")
	checkError(err)
	ModelDBMaxIdleConns, err = configUtil.ReadIntJsonValue(config, "ModelDBMaxIdleConns")
	checkError(err)

	// 解析GameDBConnection配置
	GameDBConnection, err = configUtil.ReadStringJsonValue(config, "GameDBConnection")
	checkError(err)
	GameDBMaxOpenConns, err = configUtil.ReadIntJsonValue(config, "GameDBMaxOpenConns")
	checkError(err)
	GameDBMaxIdleConns, err = configUtil.ReadIntJsonValue(config, "GameDBMaxIdleConns")
	checkError(err)
}