업데이트

This commit is contained in:
2025-12-28 14:55:00 +09:00
parent 40182b4e2d
commit 3defa9abd7
5 changed files with 14 additions and 31 deletions

View File

@@ -13,7 +13,7 @@ let pool: pg.Pool | null = null
*/
export function getPool(): pg.Pool {
if (!pool) {
pool = new Pool({
const config = {
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
database: process.env.DB_NAME || 'osolit_monitor',
@@ -22,7 +22,11 @@ export function getPool(): pg.Pool {
max: 10,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
})
}
console.log(`[DB] Connecting to ${config.host}:${config.port}/${config.database}`)
pool = new Pool(config)
pool.on('error', (err) => {
console.error('[DB] Unexpected pool error:', err)