From 1c3386e87f947d5b1dabb9be6a3b1a5d0fbf0d50 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 28 Jul 2018 21:02:26 +0200 Subject: [PATCH] adding ORM pool configuration --- config/default.yaml | 2 ++ config/production.yaml.example | 2 ++ server/initializers/checker.ts | 2 +- server/initializers/constants.ts | 5 ++++- server/initializers/database.ts | 4 ++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index bc0530d79..3b877476d 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -22,6 +22,8 @@ database: suffix: '_dev' username: 'peertube' password: 'peertube' + pool: + max: 5 # You can also specify a 'socket' path to a unix socket but first need to # comment out hostname and port diff --git a/config/production.yaml.example b/config/production.yaml.example index d347b0ece..6087e78be 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -21,6 +21,8 @@ database: suffix: '_prod' username: 'peertube' password: 'peertube' + pool: + max: 5 # Redis server for short time storage # You can also specify a 'socket' path to a unix socket but first need to diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index 52a1aeb50..270cbf649 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts @@ -43,7 +43,7 @@ function checkMissedConfig () { const required = [ 'listen.port', 'listen.hostname', 'webserver.https', 'webserver.hostname', 'webserver.port', 'trust_proxy', - 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', + 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 'log.level', diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 3aa979668..6256cf38e 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -121,7 +121,10 @@ const CONFIG = { HOSTNAME: config.get('database.hostname'), PORT: config.get('database.port'), USERNAME: config.get('database.username'), - PASSWORD: config.get('database.password') + PASSWORD: config.get('database.password'), + POOL: { + MAX: config.get('database.pool.max') + } }, REDIS: { HOSTNAME: config.has('redis.hostname') ? config.get('redis.hostname') : null, diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 1a9ce5a61..21c083084 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -32,6 +32,7 @@ const username = CONFIG.DATABASE.USERNAME const password = CONFIG.DATABASE.PASSWORD const host = CONFIG.DATABASE.HOSTNAME const port = CONFIG.DATABASE.PORT +const poolMax = CONFIG.DATABASE.POOL.MAX const sequelizeTypescript = new SequelizeTypescript({ database: dbname, @@ -40,6 +41,9 @@ const sequelizeTypescript = new SequelizeTypescript({ port, username, password, + pool: { + max: poolMax + }, benchmark: isTestInstance(), isolationLevel: SequelizeTypescript.Transaction.ISOLATION_LEVELS.SERIALIZABLE, operatorsAliases: false,