38 lines
730 B
JavaScript
38 lines
730 B
JavaScript
require('dotenv').config();
|
|
|
|
const app = require('./src/app');
|
|
|
|
let shuttingDown = false;
|
|
|
|
async function shutdown(signal) {
|
|
if (shuttingDown) return;
|
|
shuttingDown = true;
|
|
try {
|
|
console.log(`Received ${signal}, shutting down…`);
|
|
await app.stop();
|
|
} catch (err) {
|
|
console.error('Shutdown error:', err);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
process.on('SIGTERM', () => {
|
|
void shutdown('SIGTERM');
|
|
});
|
|
process.on('SIGINT', () => {
|
|
void shutdown('SIGINT');
|
|
});
|
|
|
|
const start = async () => {
|
|
try {
|
|
await app.start();
|
|
console.log(`Concierge server running at: ${app.info.uri}`);
|
|
} catch (err) {
|
|
console.error('Failed to start concierge server:', err);
|
|
process.exit(1);
|
|
}
|
|
};
|
|
|
|
start();
|