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 () => {
|
const startServer = async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('🔄 Connecting to database...');
|
||||||
await connectDB();
|
await connectDB();
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = parseInt(process.env.PORT || '3000', 10);
|
||||||
app.listen(PORT, async () => {
|
|
||||||
|
const server = app.listen(PORT, '0.0.0.0', () => {
|
||||||
console.log(`🚀 Server running on port ${PORT}`);
|
console.log(`🚀 Server running on port ${PORT}`);
|
||||||
console.log('✅ Conectado ao Supabase (GPI schema)');
|
console.log('✅ Conectado ao Supabase (GPI schema)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.timeout = 60000;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to start server:', error);
|
console.error('Failed to start server:', error);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
startServer();
|
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