diff --git a/src/server/index.ts b/src/server/index.ts index 3ddc726..e128384 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -7,18 +7,30 @@ import { notificationService } from './services/notificationService.js'; const startServer = async () => { try { + console.log('🔄 Connecting to database...'); await connectDB(); - const PORT = process.env.PORT || 3000; - app.listen(PORT, async () => { + const PORT = parseInt(process.env.PORT || '3000', 10); + + const server = app.listen(PORT, '0.0.0.0', () => { console.log(`🚀 Server running on port ${PORT}`); console.log('✅ Conectado ao Supabase (GPI schema)'); }); + + server.timeout = 60000; + } catch (error) { console.error('Failed to start server:', error); + process.exit(1); } }; startServer(); -setInterval(() => { }, 1000); +process.on('uncaughtException', (err) => { + console.error('Uncaught Exception:', err); +}); + +process.on('unhandledRejection', (reason) => { + console.error('Unhandled Rejection:', reason); +});