This commit is contained in:
xing 2023-04-11 13:42:14 +08:00
parent db49f99c04
commit 125764711d
2 changed files with 4 additions and 4 deletions

View File

@ -20,9 +20,6 @@ func InitDb() (*safety.Var[*sqlx.DB], error) {
return nil, err
}
preDb := safeDb.Load()
if preDb != nil {
_ = preDb.Close()
}
if c.Mysql.Pool.ConnMaxIdleTime != 0 {
db.SetConnMaxIdleTime(c.Mysql.Pool.ConnMaxLifetime)
}
@ -36,6 +33,9 @@ func InitDb() (*safety.Var[*sqlx.DB], error) {
db.SetConnMaxLifetime(c.Mysql.Pool.ConnMaxLifetime)
}
safeDb.Store(db)
if preDb != nil {
_ = preDb.Close()
}
return safeDb, err
}

View File

@ -35,10 +35,10 @@ func InitLogger() error {
out = file
logFile.Store(file)
}
logs.Store(l)
if preFD != nil {
_ = preFD.Close()
}
logs.Store(l)
l.SetFlags(log.Ldate | log.Ltime)
l.SetOutput(out)
return nil