mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 01:34:27 +00:00 
			
		
		
		
	fix possbile mysql invalid connnection error (#7051)
This commit is contained in:
		@@ -14,6 +14,7 @@ import (
 | 
				
			|||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"code.gitea.io/gitea/modules/setting"
 | 
						"code.gitea.io/gitea/modules/setting"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -278,6 +279,11 @@ func SetEngine() (err error) {
 | 
				
			|||||||
	// so use log file to instead print to stdout.
 | 
						// so use log file to instead print to stdout.
 | 
				
			||||||
	x.SetLogger(NewXORMLogger(setting.LogSQL))
 | 
						x.SetLogger(NewXORMLogger(setting.LogSQL))
 | 
				
			||||||
	x.ShowSQL(setting.LogSQL)
 | 
						x.ShowSQL(setting.LogSQL)
 | 
				
			||||||
 | 
						if DbCfg.Type == "mysql" {
 | 
				
			||||||
 | 
							x.SetMaxIdleConns(0)
 | 
				
			||||||
 | 
							x.SetConnMaxLifetime(3 * time.Second)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user