diff --git a/internal/pkg/db/db.go b/internal/pkg/db/db.go index b1b78cd..87919a4 100644 --- a/internal/pkg/db/db.go +++ b/internal/pkg/db/db.go @@ -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) }