mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
commit
317720bfc8
@ -748,6 +748,9 @@ datastore:
|
|||||||
password: "hunter2"
|
password: "hunter2"
|
||||||
history-database: "oragono_history"
|
history-database: "oragono_history"
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
|
max-conns: 4
|
||||||
|
# this may be necessary to prevent middleware from closing your connections:
|
||||||
|
#conn-max-lifetime: 180s
|
||||||
|
|
||||||
# languages config
|
# languages config
|
||||||
languages:
|
languages:
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -1481,6 +1482,12 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||||||
|
|
||||||
config.Datastore.MySQL.ExpireTime = time.Duration(config.History.Restrictions.ExpireTime)
|
config.Datastore.MySQL.ExpireTime = time.Duration(config.History.Restrictions.ExpireTime)
|
||||||
config.Datastore.MySQL.TrackAccountMessages = config.History.Retention.EnableAccountIndexing
|
config.Datastore.MySQL.TrackAccountMessages = config.History.Retention.EnableAccountIndexing
|
||||||
|
if config.Datastore.MySQL.MaxConns == 0 {
|
||||||
|
// #1622: not putting an upper limit on the number of MySQL connections is
|
||||||
|
// potentially dangerous. as a naive heuristic, assume they're running on the
|
||||||
|
// same machine:
|
||||||
|
config.Datastore.MySQL.MaxConns = runtime.NumCPU()
|
||||||
|
}
|
||||||
|
|
||||||
config.Server.Cloaks.Initialize()
|
config.Server.Cloaks.Initialize()
|
||||||
if config.Server.Cloaks.Enabled {
|
if config.Server.Cloaks.Enabled {
|
||||||
|
@ -17,6 +17,8 @@ type Config struct {
|
|||||||
Password string
|
Password string
|
||||||
HistoryDatabase string `yaml:"history-database"`
|
HistoryDatabase string `yaml:"history-database"`
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
MaxConns int `yaml:"max-conns"`
|
||||||
|
ConnMaxLifetime time.Duration `yaml:"conn-max-lifetime"`
|
||||||
|
|
||||||
// XXX these are copied from elsewhere in the config:
|
// XXX these are copied from elsewhere in the config:
|
||||||
ExpireTime time.Duration
|
ExpireTime time.Duration
|
||||||
|
@ -100,6 +100,14 @@ func (m *MySQL) Open() (err error) {
|
|||||||
return err
|
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()
|
err = m.fixSchemas()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -721,6 +721,9 @@ datastore:
|
|||||||
password: "hunter2"
|
password: "hunter2"
|
||||||
history-database: "oragono_history"
|
history-database: "oragono_history"
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
|
max-conns: 4
|
||||||
|
# this may be necessary to prevent middleware from closing your connections:
|
||||||
|
#conn-max-lifetime: 180s
|
||||||
|
|
||||||
# languages config
|
# languages config
|
||||||
languages:
|
languages:
|
||||||
|
Loading…
Reference in New Issue
Block a user