diff --git a/models/db/engine.go b/models/db/engine.go index f1162ebd6..660ea1f5e 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -146,6 +146,7 @@ func InitEngine(ctx context.Context) error { xormEngine.SetMaxOpenConns(setting.Database.MaxOpenConns) xormEngine.SetMaxIdleConns(setting.Database.MaxIdleConns) xormEngine.SetConnMaxLifetime(setting.Database.ConnMaxLifetime) + xormEngine.SetConnMaxIdleTime(setting.Database.ConnMaxIdleTime) xormEngine.SetDefaultContext(ctx) if setting.Database.SlowQueryThreshold > 0 { diff --git a/modules/setting/database.go b/modules/setting/database.go index c7bc92e67..47d79d0de 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -42,6 +42,7 @@ var ( DBConnectBackoff time.Duration MaxIdleConns int MaxOpenConns int + ConnMaxIdleTime time.Duration ConnMaxLifetime time.Duration IterateBufferSize int AutoMigration bool @@ -81,6 +82,7 @@ func loadDBSetting(rootCfg ConfigProvider) { } else { Database.ConnMaxLifetime = sec.Key("CONN_MAX_LIFETIME").MustDuration(0) } + Database.ConnMaxIdleTime = sec.Key("CONN_MAX_IDLETIME").MustDuration(0) Database.MaxOpenConns = sec.Key("MAX_OPEN_CONNS").MustInt(0) Database.IterateBufferSize = sec.Key("ITERATE_BUFFER_SIZE").MustInt(50)