diff --git a/common/common.go b/common/common.go index 8c0f79bea3..59dd960345 100644 --- a/common/common.go +++ b/common/common.go @@ -244,8 +244,10 @@ func connectDB(host, user, pass, dbName string) error { PQ = db.DB() boil.SetDB(PQ) if err == nil { - PQ.SetMaxOpenConns(3) - PQ.SetMaxIdleConns(3) + maxConns := confMaxSQLConns.GetInt() + PQ.SetMaxOpenConns(maxConns) + PQ.SetMaxIdleConns(maxConns) + logger.Infof("Set max PG connections to %d", maxConns) } GORM.SetLogger(&GORMLogger{}) diff --git a/common/config.go b/common/config.go index ab33845d87..b89f697074 100644 --- a/common/config.go +++ b/common/config.go @@ -30,6 +30,8 @@ var ( ConfDogStatsdAddress = config.RegisterOption("yagpdb.dogstatsdaddress", "dogstatsd address", "") confNoSchemaInit = config.RegisterOption("yagpdb.no_schema_init", "Disable schema intiialization", false) + confMaxSQLConns = config.RegisterOption("yagdb.pq_max_conns", "Max connections to postgres", 3) + BotOwners []int64 ) @@ -45,7 +47,7 @@ func LoadConfig() (err error) { config.AddSource(&config.EnvSource{}) config.AddSource(&config.RedisConfigStore{Pool: RedisPool}) config.Load() - + requiredConf := []*config.ConfigOption{ ConfClientID, ConfClientSecret,