Пример #1
0
func InitDB() {
	separator := utils.OsSeparator()
	config_file := revel.BasePath + separator + "conf" + separator + "databases.conf"

	c, _ := config.ReadDefault(config_file)

	guildcore_driver, _ := c.String("database", "db.guild_core.driver")
	guildcore_dbname, _ := c.String("database", "db.guild_core.dbname")
	guildcore_user, _ := c.String("database", "db.guild_core.user")
	guildcore_password, _ := c.String("database", "db.guild_core.password")
	guildcore_host, _ := c.String("database", "db.guild_core.host")

	var err error
	DB, err = xorm.NewEngine(guildcore_driver, fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", guildcore_user, guildcore_password, guildcore_host, guildcore_dbname))
	if err != nil {
		revel.WARN.Printf("DB 错误:%v", err)
	}
}
Пример #2
0
func InitBizService() {
	separator := utils.OsSeparator()
	config_file := revel.BasePath + separator + "conf" + separator + "api.conf"

	c, _ := config.ReadDefault(config_file)

	/*
	   bizService.addr=127.0.0.1:9151
	   bizService.caller=guild.website
	   bizService.secretkey=04ab5c51ew81c353g4dc2y0d2f6x51ma
	*/

	bizService_addr, _ := c.String("api", "bizService.addr")
	bizService_caller, _ := c.String("api", "bizService.caller")
	bizService_secretkey, _ := c.String("api", "db.guild_core.user")

	BizAddress = "http://" + bizService_addr
	BizCaller = bizService_caller
	BizSecretKey = bizService_secretkey

	Md5Ctx = md5.New()

}