diff --git a/server/db.ts b/server/db.ts index 8a1c88d..6083fdf 100644 --- a/server/db.ts +++ b/server/db.ts @@ -4,9 +4,9 @@ import * as schema from "@shared/schema"; const isProduction = process.env.NODE_ENV === 'production'; const dbUrl = process.env.DATABASE_URL; -console.log('🔗 Database initialization:', { - NODE_ENV: process.env.NODE_ENV, - isProduction, +console.log('🔗 Database initialization:', { + NODE_ENV: process.env.NODE_ENV, + isProduction, hasDbUrl: !!dbUrl, dbHost: dbUrl ? new URL(dbUrl).hostname : 'none' }); @@ -19,17 +19,17 @@ if (isProduction && dbUrl && (dbUrl.includes('logiflow-db') || dbUrl.includes('l console.log('🐳 PRODUCTION: Using standard PostgreSQL'); const { Pool } = await import('pg'); const { drizzle } = await import('drizzle-orm/node-postgres'); - - pool = new Pool({ + + pool = new Pool({ connectionString: dbUrl, ssl: false, - max: 10, + max: 25, // Increased from 10 to handle concurrent verifications idleTimeoutMillis: 30000, - connectionTimeoutMillis: 5000, + connectionTimeoutMillis: 15000, // Increased from 5000 to 15000 }); - + db = drizzle({ client: pool, schema }); - + // Test connection try { await pool.connect().then((client: any) => { @@ -45,9 +45,9 @@ if (isProduction && dbUrl && (dbUrl.includes('logiflow-db') || dbUrl.includes('l const { Pool, neonConfig } = await import('@neondatabase/serverless'); const { drizzle } = await import('drizzle-orm/neon-serverless'); const ws = await import('ws'); - + neonConfig.webSocketConstructor = ws.default; - + if (dbUrl) { pool = new Pool({ connectionString: dbUrl }); db = drizzle({ client: pool, schema });