mirror of
https://github.com/seerr-team/seerr.git
synced 2026-05-19 06:07:27 -04:00
feat(db): add DB_POOL_SIZE environment variable for postgres connection pool (#2990)
This commit is contained in:
@@ -14,6 +14,7 @@ services:
|
||||
DB_NAME: 'seerr' # The name of the database to connect to
|
||||
DB_LOG_QUERIES: 'false' # Whether to log the DB queries for debugging
|
||||
DB_USE_SSL: 'false' # Whether to enable ssl for database connection
|
||||
DB_POOL_SIZE: '10' # The number of connections to maintain in the connection pool
|
||||
volumes:
|
||||
- .:/app:rw,cached
|
||||
- /app/node_modules
|
||||
|
||||
@@ -35,6 +35,7 @@ DB_PORT="5432" # (optional) The port to connect to. The default is "5432".
|
||||
DB_USER= # (required) Username used to connect to the database.
|
||||
DB_PASS= # (required) Password of the user used to connect to the database.
|
||||
DB_NAME="seerr" # (optional) The name of the database to connect to. The default is "seerr".
|
||||
DB_POOL_SIZE="10" # (optional) The number of connections to maintain in the connection pool. The default is "10".
|
||||
DB_LOG_QUERIES="false" # (optional) Whether to log the DB queries for debugging. The default is "false".
|
||||
```
|
||||
|
||||
@@ -48,6 +49,7 @@ DB_SOCKET_PATH="/var/run/postgresql" # (required) The path to the PostgreSQL Uni
|
||||
DB_USER= # (required) Username used to connect to the database.
|
||||
DB_PASS= # (optional) Password of the user used to connect to the database, depending on the server's authentication configuration.
|
||||
DB_NAME="seerr" # (optional) The name of the database to connect to. The default is "seerr".
|
||||
DB_POOL_SIZE="10" # (optional) The number of connections to maintain in the connection pool. The default is "10".
|
||||
DB_LOG_QUERIES="false" # (optional) Whether to log the DB queries for debugging. The default is "false".
|
||||
```
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@ function boolFromEnv(envVar: string, defaultVal = false) {
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
function intFromEnv(envVar: string, defaultVal?: number): number | undefined {
|
||||
const val = process.env[envVar];
|
||||
if (val) {
|
||||
const parsed = parseInt(val, 10);
|
||||
return isNaN(parsed) ? defaultVal : parsed;
|
||||
}
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
function stringOrReadFileFromEnv(envVar: string): Buffer | string | undefined {
|
||||
if (process.env[envVar]) {
|
||||
return process.env[envVar];
|
||||
@@ -87,6 +96,7 @@ const postgresDevConfig: DataSourceOptions = {
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME ?? 'seerr',
|
||||
ssl: buildSslConfig(),
|
||||
poolSize: intFromEnv('DB_POOL_SIZE'),
|
||||
synchronize: false,
|
||||
migrationsRun: true,
|
||||
logging: boolFromEnv('DB_LOG_QUERIES'),
|
||||
@@ -105,6 +115,7 @@ const postgresProdConfig: DataSourceOptions = {
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME ?? 'seerr',
|
||||
ssl: buildSslConfig(),
|
||||
poolSize: intFromEnv('DB_POOL_SIZE'),
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
logging: boolFromEnv('DB_LOG_QUERIES'),
|
||||
|
||||
Reference in New Issue
Block a user