@@ -146,13 +146,32 @@ app.use((req, res) => {
146146 res . status ( 404 ) . sendFile ( path . join ( __dirname , 'public' , '404.html' ) ) ;
147147} )
148148
149- // Export für Passenger
150- module . exports = app
149+ // Better error handling for uncaught exceptions
150+ process . on ( 'uncaughtException' , ( err ) => {
151+ console . error ( 'Uncaught exception:' , err ) ;
152+ // Don't exit the process, just log the error
153+ } ) ;
154+
155+ // Better error handling for unhandled promise rejections
156+ process . on ( 'unhandledRejection' , ( reason , promise ) => {
157+ console . error ( 'Unhandled Rejection at:' , promise , 'reason:' , reason ) ;
158+ // Don't exit the process, just log the error
159+ } ) ;
151160
152- // Start Server wenn direkt ausgeführt
153- if ( require . main === module ) {
154- const port = process . env . PORT || 80
161+ // Improve the export for Passenger
162+ if ( typeof ( PhusionPassenger ) !== 'undefined' ) {
163+ PhusionPassenger . configure ( { autoInstall : false } ) ;
164+
165+ const port = process . env . PORT || 80 ;
166+ app . listen ( port , '0.0.0.0' , ( ) => {
167+ console . log ( `VATSIM PMP running in Passenger mode on port ${ port } ` ) ;
168+ } ) ;
169+ } else if ( require . main === module ) {
170+ const port = process . env . PORT || 80 ;
155171 app . listen ( port , ( ) => {
156- console . log ( `VATSIM PMP running on port ${ port } ` )
157- } )
172+ console . log ( `VATSIM PMP running in standalone mode on port ${ port } ` ) ;
173+ } ) ;
158174}
175+
176+ // Export for Passenger
177+ module . exports = app
0 commit comments