package db import ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "golib.gaore.com/GaoreGo/grlogs" ) func LoadOrm(dsns map[string]dsnConfig) (err error) { for alias, dsn := range dsns { grlogs.Debug("init_db 正在加载数据 ", dsn) err = orm.RegisterDataBase(alias, dsn.Driver, dsn.Dsn, 10, 10) orm.SetMaxIdleConns(alias, 1000) orm.SetMaxOpenConns(alias, 1000) d, _ := orm.GetDB(alias) d.SetConnMaxLifetime(3600) } grlogs.Debug("init_db 加载数据库完成") // 测试环境下输出sql runmode := beego.BConfig.RunMode if runmode == "dev" { orm.Debug = true } return }