fix possbile mysql invalid connnection error (#7051) (#7071)

This commit is contained in:
Lunny Xiao 2019-05-29 17:49:03 +08:00 committed by zeripath
parent 8d5c3d3d0b
commit 63cb160cb1
1 changed files with 6 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import (
"path"
"path/filepath"
"strings"
"time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@ -277,6 +278,11 @@ func SetEngine() (err error) {
// so use log file to instead print to stdout.
x.SetLogger(log.XORMLogger)
x.ShowSQL(setting.LogSQL)
if DbCfg.Type == "mysql" {
x.SetMaxIdleConns(0)
x.SetConnMaxLifetime(3 * time.Second)
}
return nil
}