fix: add server error handling and listen on 0.0.0.0
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user