mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
fix #1622
Allow users to set max MySQL connections and connection lifetime; set a sane default for max connections if it's not present.
This commit is contained in:
parent
a2b5548c8b
commit
5eed48c077
5 changed files with 23 additions and 0 deletions
|
|
@ -100,6 +100,14 @@ func (m *MySQL) Open() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if m.config.MaxConns != 0 {
|
||||
m.db.SetMaxOpenConns(m.config.MaxConns)
|
||||
m.db.SetMaxIdleConns(m.config.MaxConns)
|
||||
}
|
||||
if m.config.ConnMaxLifetime != 0 {
|
||||
m.db.SetConnMaxLifetime(m.config.ConnMaxLifetime)
|
||||
}
|
||||
|
||||
err = m.fixSchemas()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue