set mysql connection

This commit is contained in:
skiffer-git
2022-08-29 22:31:14 +08:00
committed by Xinwei Xiong(cubxxw-openim)
parent ae86caf39e
commit 5709238c2b
3 changed files with 12 additions and 3 deletions
+9
View File
@@ -52,6 +52,15 @@ func initMysqlDB() {
panic(err.Error())
}
sqlDB, err := db.DB()
if err != nil {
panic(err.Error())
}
sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.DBMaxLifeTime))
sqlDB.SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns)
sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns)
fmt.Println("open db ok ", dsn)
db.AutoMigrate(
&Register{},