fix: connection pool settings
This commit is contained in:
parent
bca25a7a52
commit
a194d8594b
1 changed files with 12 additions and 2 deletions
|
|
@ -47,8 +47,8 @@ export const AppDataSource = new DataSource({
|
|||
logging: true,
|
||||
// timezone: "Z",
|
||||
entities:
|
||||
process.env.NODE_ENV !== "production"
|
||||
? ["src/entities/**/*.ts"]
|
||||
process.env.NODE_ENV !== "production"
|
||||
? ["src/entities/**/*.ts"]
|
||||
: ["dist/entities/**/*{.ts,.js}"],
|
||||
migrations:
|
||||
process.env.NODE_ENV !== "production"
|
||||
|
|
@ -56,6 +56,16 @@ export const AppDataSource = new DataSource({
|
|||
: ["dist/migration/**/*{.ts,.js}"],
|
||||
subscribers: [],
|
||||
logger: new MyCustomLogger(),
|
||||
// Connection pool settings to prevent connection exhaustion
|
||||
extra: {
|
||||
connectionLimit: +(process.env.DB_CONNECTION_LIMIT || 50),
|
||||
maxIdle: +(process.env.DB_MAX_IDLE || 10),
|
||||
idleTimeout: +(process.env.DB_IDLE_TIMEOUT || 60000),
|
||||
timezone: "+07:00", // Bangkok timezone (UTC+7)
|
||||
},
|
||||
// TypeORM pool settings
|
||||
poolSize: +(process.env.DB_POOL_SIZE || 10),
|
||||
maxQueryExecutionTime: +(process.env.DB_MAX_QUERY_TIME || 3000),
|
||||
});
|
||||
|
||||
// export default database;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue