diff --git a/config/config.yaml b/config/config.yaml index c9b09b691..5d3908934 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -16,9 +16,9 @@ mysql: dbMysqlDatabaseName: openIM_v2 #默认即可 dbTableName: eMsg #默认即可 dbMsgTableNum: 1 - dbMaxOpenConns: 200 + dbMaxOpenConns: 2000 dbMaxIdleConns: 100 - dbMaxLifeTime: 120 + dbMaxLifeTime: 3600 mongo: dbUri: ""#当dbUri值不为空则直接使用该值 diff --git a/internal/api/user/user.go b/internal/api/user/user.go index e6867fa9a..7088c04bd 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -166,7 +166,7 @@ func GetSelfUserInfo(c *gin.Context) { c.JSON(http.StatusOK, resp) } else { resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}} - log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) + log.NewError(req.OperationID, "GetUserInfo api return ", resp) c.JSON(http.StatusOK, resp) } } diff --git a/pkg/common/db/mysql.go b/pkg/common/db/mysql.go index 75b536d05..a2050fbf1 100644 --- a/pkg/common/db/mysql.go +++ b/pkg/common/db/mysql.go @@ -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{},