@@ -141,39 +141,39 @@ app.use('*', (req, res) => {
141141
142142// Error handling middleware (must be last)
143143app . use ( errorHandler ) ;
144-
145- // Start server
146- const startServer = ( port ) => {
147- const server = app . listen ( port , ( ) => {
148- console . log ( `🚀 LeetCode, CodeChef & GeeksforGeeks API Server is running on port ${ port } ` ) ;
149- console . log ( `📚 API Documentation: http://localhost:${ port } /` ) ;
150- console . log ( `🔍 Health Check: http://localhost:${ port } /health` ) ;
151- console . log ( `🎯 Environment: ${ process . env . NODE_ENV || 'development' } ` ) ;
152- } ) ;
153-
154- server . on ( 'error' , ( err ) => {
155- if ( err . code === 'EADDRINUSE' ) {
156- console . log ( `Port ${ port } is busy, trying port ${ port + 1 } ...` ) ;
157- startServer ( port + 1 ) ;
158- } else {
159- console . error ( 'Server error:' , err ) ;
160- }
161- } ) ;
162-
163- return server ;
164- } ;
165-
166- startServer ( PORT ) ;
167-
168- // Graceful shutdown
169- process . on ( 'SIGTERM' , ( ) => {
170- console . log ( 'SIGTERM received, shutting down gracefully' ) ;
171- process . exit ( 0 ) ;
172- } ) ;
173-
174- process . on ( 'SIGINT' , ( ) => {
175- console . log ( 'SIGINT received, shutting down gracefully' ) ;
176- process . exit ( 0 ) ;
144+ const port = PORT ;
145+ app . listen ( port , ( ) => {
146+ console . log ( `🚀 LeetCode, CodeChef & GeeksforGeeks API Server is running on port ${ port } ` ) ;
147+ console . log ( `📚 API Documentation: http://localhost:${ port } /` ) ;
148+ console . log ( `🔍 Health Check: http://localhost:${ port } /health` ) ;
149+ console . log ( `🎯 Environment: ${ process . env . NODE_ENV || 'development' } ` ) ;
177150} ) ;
151+ // Start server
152+ // const startServer = (port) => {
153+
154+ // server.on('error', (err) => {
155+ // if (err.code === 'EADDRINUSE') {
156+ // console.log(`Port ${port} is busy, trying port ${port + 1}...`);
157+ // startServer(port + 1);
158+ // } else {
159+ // console.error('Server error:', err);
160+ // }
161+ // });
162+
163+ // return server;
164+ // };
165+
166+ // startServer(PORT);
167+
168+ // // Graceful shutdown
169+ // process.on('SIGTERM', () => {
170+ // console.log('SIGTERM received, shutting down gracefully');
171+ // process.exit(0);
172+ // });
173+
174+ // process.on('SIGINT', () => {
175+ // console.log('SIGINT received, shutting down gracefully');
176+ // process.exit(0);
177+ // });
178178
179179export default app ;
0 commit comments