reload时close db
This commit is contained in:
parent
0d8ee89580
commit
db49f99c04
|
@ -19,6 +19,10 @@ func InitDb() (*safety.Var[*sqlx.DB], error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
preDb := safeDb.Load()
|
||||
if preDb != nil {
|
||||
_ = preDb.Close()
|
||||
}
|
||||
if c.Mysql.Pool.ConnMaxIdleTime != 0 {
|
||||
db.SetConnMaxIdleTime(c.Mysql.Pool.ConnMaxLifetime)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user