Browse Source

fix possbile mysql invalid connnection error (#7051)

for-closed-social
Lunny Xiao 5 years ago
committed by Lauris BH
parent
commit
c2f3938a58
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      models/models.go

+ 6
- 0
models/models.go View File

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

Loading…
Cancel
Save