package models import ( "eta/eta_data_init/utils" "github.com/beego/beego/v2/client/orm" _ "github.com/go-sql-driver/mysql" "time" ) func init() { if utils.MYSQL_URL_ETA != "" { _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_ETA) orm.SetMaxIdleConns("default", 50) orm.SetMaxOpenConns("default", 100) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) _ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA) orm.SetMaxIdleConns("eta", 50) orm.SetMaxOpenConns("eta", 100) etaDb, _ := orm.GetDB("eta") etaDb.SetConnMaxLifetime(10 * time.Minute) orm.RegisterModel( new(Admin), ) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) } if utils.MYSQL_URL_DATA != "" { _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA) orm.SetMaxIdleConns("data", 50) orm.SetMaxOpenConns("data", 100) etaDb, _ := orm.GetDB("data") etaDb.SetConnMaxLifetime(10 * time.Minute) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) } }