From 8bd10835029a035a798e51da7fffb2dcee695668 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 May 2019 20:03:31 +0800 Subject: [PATCH] fix possbile mysql invalid connnection error --- models/models.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/models.go b/models/models.go index 85318af870dc3..c1d4c100d0027 100644 --- a/models/models.go +++ b/models/models.go @@ -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 }