mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
set mysql connection
This commit is contained in:
parent
ae86caf39e
commit
5709238c2b
@ -16,9 +16,9 @@ mysql:
|
|||||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||||
dbTableName: eMsg #默认即可
|
dbTableName: eMsg #默认即可
|
||||||
dbMsgTableNum: 1
|
dbMsgTableNum: 1
|
||||||
dbMaxOpenConns: 200
|
dbMaxOpenConns: 2000
|
||||||
dbMaxIdleConns: 100
|
dbMaxIdleConns: 100
|
||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 3600
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
|
@ -166,7 +166,7 @@ func GetSelfUserInfo(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
} else {
|
} else {
|
||||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}
|
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)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,15 @@ func initMysqlDB() {
|
|||||||
panic(err.Error())
|
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)
|
fmt.Println("open db ok ", dsn)
|
||||||
db.AutoMigrate(
|
db.AutoMigrate(
|
||||||
&Register{},
|
&Register{},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user