)
type wsConfig struct {
- Client arvados.Client
- Postgres pgConfig
- Listen string
- LogLevel string
- LogFormat string
+ Client arvados.Client
+ Postgres pgConfig
+ PostgresPool int
+ Listen string
+ LogLevel string
+ LogFormat string
PingTimeout arvados.Duration
ClientEventQueue int
APIHost: "localhost:443",
},
Postgres: pgConfig{
- "dbname": "arvados_production",
- "user": "arvados",
- "password": "xyzzy",
- "host": "localhost",
- "connect_timeout": "30",
- "sslmode": "require",
+ "dbname": "arvados_production",
+ "user": "arvados",
+ "password": "xyzzy",
+ "host": "localhost",
+ "connect_timeout": "30",
+ "sslmode": "require",
+ "fallback_application_name": "arvados-ws",
},
+ PostgresPool: 64,
LogLevel: "info",
LogFormat: "json",
PingTimeout: arvados.Duration(time.Minute),
}
type pgEventSource struct {
- DataSource string
- QueueSize int
+ DataSource string
+ MaxOpenConns int
+ QueueSize int
db *sql.DB
pqListener *pq.Listener
logger(nil).WithError(err).Error("sql.Open failed")
return
}
+ if ps.MaxOpenConns <= 0 {
+ logger(nil).Warn("no database connection limit configured -- consider setting PostgresPool>0 in arvados-ws configuration file")
+ }
+ db.SetMaxOpenConns(ps.MaxOpenConns)
if err = db.Ping(); err != nil {
logger(nil).WithError(err).Error("db.Ping failed")
return
srv.listener = ln
srv.eventSource = &pgEventSource{
- DataSource: srv.wsConfig.Postgres.ConnectionString(),
- QueueSize: srv.wsConfig.ServerEventQueue,
+ DataSource: srv.wsConfig.Postgres.ConnectionString(),
+ MaxOpenConns: srv.wsConfig.PostgresPool,
+ QueueSize: srv.wsConfig.ServerEventQueue,
}
srv.httpServer = &http.Server{
Addr: srv.wsConfig.Listen,