fix: add server error handling and listen on 0.0.0.0

This commit is contained in:
2026-03-31 13:13:38 +00:00
parent f9a07cddff
commit 11d8268d1c

View File

@@ -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);
});