MVP Build
This commit is contained in:
45
backend/src/index.ts
Normal file
45
backend/src/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @ai-summary Application entry point
|
||||
* @ai-context Starts the Express server with all feature capsules
|
||||
*/
|
||||
import { app } from './app';
|
||||
import { env } from './core/config/environment';
|
||||
import { logger } from './core/logging/logger';
|
||||
|
||||
const PORT = env.PORT || 3001;
|
||||
|
||||
const server = app.listen(PORT, () => {
|
||||
logger.info(`MotoVaultPro backend running`, {
|
||||
port: PORT,
|
||||
environment: env.NODE_ENV,
|
||||
nodeVersion: process.version,
|
||||
});
|
||||
});
|
||||
|
||||
// Graceful shutdown
|
||||
process.on('SIGTERM', () => {
|
||||
logger.info('SIGTERM received, shutting down gracefully');
|
||||
server.close(() => {
|
||||
logger.info('Server closed');
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
logger.info('SIGINT received, shutting down gracefully');
|
||||
server.close(() => {
|
||||
logger.info('Server closed');
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
// Handle uncaught exceptions
|
||||
process.on('uncaughtException', (error) => {
|
||||
logger.error('Uncaught Exception', { error: error.message, stack: error.stack });
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
logger.error('Unhandled Rejection', { reason, promise });
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user