Skip to content

Commit

Permalink
fix possbile mysql invalid connnection error (#7051)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed May 29, 2019
1 parent 8d5c3d3 commit ecb1788
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path"
"path/filepath"
"strings"
"time"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit ecb1788

Please sign in to comment.