Skip to content

Commit

Permalink
style: Update database connection pool timeouts to 60 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Sep 7, 2024
1 parent a47796b commit 3734aa9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/db/knexfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import type { Knex } from 'knex';
import path from 'node:path';
import { databaseConfig, appConfig } from '../config';

// const developmentEnvironmentOnly = appConfig.env === 'development';
const developmentEnvironmentOnly = appConfig.env === 'development';

const knexConfig: Knex.Config = {
client: 'pg',
// connection: `postgresql://${databaseConfig.username}:${databaseConfig.password}@${databaseConfig.host}/${databaseConfig.database}`,
connection: {
database: databaseConfig.database,
host: databaseConfig.host,
Expand All @@ -18,14 +17,14 @@ const knexConfig: Knex.Config = {
tableName: 'knex_migrations',
directory: path.resolve(__dirname, './migrations'),
},
// debug: developmentEnvironmentOnly,
debug: developmentEnvironmentOnly,
seeds: { directory: path.resolve(__dirname, './seeds') },
pool: {
min: 2,
max: 10,
acquireTimeoutMillis: 30000, // 30 seconds
createTimeoutMillis: 30000, // 30 seconds
idleTimeoutMillis: 30000, // 30 seconds
acquireTimeoutMillis: 60000, // Increase to 60 seconds
createTimeoutMillis: 60000, // Increase to 60 seconds
idleTimeoutMillis: 60000, // Increase to 60 seconds
reapIntervalMillis: 1000, // 1 second
afterCreate: (conn: any, done: (err: Error | null, conn: any) => void) => {

Check warning on line 29 in src/db/knexfile.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

Unexpected any. Specify a different type

Check warning on line 29 in src/db/knexfile.ts

View workflow job for this annotation

GitHub Actions / ESLint (22.x)

Unexpected any. Specify a different type
console.info('New database connection established');
Expand Down

0 comments on commit 3734aa9

Please sign in to comment.