Commit 2e73e8c5 authored by hujiebin's avatar hujiebin

feat:调高最大连接数

parent 46669f1f
...@@ -51,8 +51,8 @@ func init() { ...@@ -51,8 +51,8 @@ func init() {
if d, err := Db.DB(); err == nil { if d, err := Db.DB(); err == nil {
d.SetConnMaxLifetime(time.Minute * 30) // 连接可复用的最大时间。 d.SetConnMaxLifetime(time.Minute * 30) // 连接可复用的最大时间。
d.SetMaxIdleConns(50) // 空闲连接数 d.SetMaxIdleConns(500) // 空闲连接数
d.SetMaxOpenConns(50) // 最大连接数 d.SetMaxOpenConns(500) // 最大连接数
if err := d.Ping(); err != nil { if err := d.Ping(); err != nil {
fmt.Printf("database ping error %v", err) fmt.Printf("database ping error %v", err)
} }
......
package main
import (
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
)
func main() {
var powerOwners []model.GroupPowerUser
if err := mysql.ProdReadOnlyDB.Model(model.GroupPowerUser{}).Where("role = 2").Find(&powerOwners).Error; err != nil {
panic(err)
}
for _, owner := range powerOwners {
var groupInfo model.GroupInfo
if err := mysql.ProdReadOnlyDB.Model(model.GroupInfo{}).Where("owner = ?", owner.UserId).First(&groupInfo).Error; err != nil {
continue
}
if owner.GroupPowerId <= 0 {
panic("0 powerId")
}
if err := mysql.ProdWriteDB.Model(model.GroupPower{}).Where("id = ?", owner.GroupPowerId).UpdateColumn("name", groupInfo.Name).Error; err != nil {
panic(err)
}
//break
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment