aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunny Xiao2019-05-29 17:49:03 +0800
committerzeripath2019-05-29 10:49:03 +0100
commit63cb160cb1e502ce28a809e8055f946f49a6e47c (patch)
tree0d493459b459998e0c72de06061fa31ce749e223
parent8d5c3d3d0b64f664a0a058389e3cfb4389560743 (diff)
fix possbile mysql invalid connnection error (#7051) (#7071)
-rw-r--r--models/models.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go
index e7ecc67fc..5f9f81f67 100644
--- a/models/models.go
+++ b/models/models.go
@@ -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
}