import app from './app'; import http from 'http'; import { initSocket } from './realtime/socket'; const PORT: number = parseInt(process.env.PORT || '5000', 10); // Start server const startServer = (): void => { try { const server = http.createServer(app); initSocket(server); server.listen(PORT, () => { console.log(`🚀 Server running on port ${PORT}`); console.log(`📊 Environment: ${process.env.NODE_ENV || 'development'}`); console.log(`🌐 API Base URL: http://localhost:${PORT}`); console.log(`❤️ Health Check: http://localhost:${PORT}/health`); console.log(`🔌 Socket.IO path: /socket.io`); }); } catch (error) { console.error('❌ Unable to start server:', error); process.exit(1); } }; // Graceful shutdown process.on('SIGTERM', () => { console.log('🛑 SIGTERM signal received: closing HTTP server'); process.exit(0); }); process.on('SIGINT', () => { console.log('🛑 SIGINT signal received: closing HTTP server'); process.exit(0); }); startServer();