Skip to content

Commit

Permalink
fix possbile mysql invalid connnection error (go-gitea#7051)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and jeffliu27 committed Jul 18, 2019
1 parent 35f1622 commit f56a9c1
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/setting"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit f56a9c1

Please sign in to comment.