From db49f99c04f198ebe48791611ccac68392c5c1b5 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 11 Apr 2023 13:11:21 +0800 Subject: [PATCH] =?UTF-8?q?reload=E6=97=B6close=20db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/db/db.go | 4 ++++ 1 file changed, 4 insertions(+) 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) }