2023-08-06 06:21:17 +00:00
|
|
|
import { app } from './app';
|
|
|
|
import { logger } from './logger';
|
2023-07-29 18:10:00 +00:00
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
const port = app.get('port');
|
|
|
|
const host = app.get('host');
|
2023-07-30 07:27:00 +00:00
|
|
|
const server = app.listen(port);
|
2023-07-29 18:10:00 +00:00
|
|
|
|
|
|
|
app.listen(port).then(() => {
|
2023-08-06 06:21:17 +00:00
|
|
|
logger.info(`Walias app listening on http://${host}:${port}`);
|
2023-07-30 07:27:00 +00:00
|
|
|
});
|
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
process.on('SIGINT', () => {
|
|
|
|
logger.info('Received SIGINT signal. Shutting down gracefully.');
|
2023-07-30 07:27:00 +00:00
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
server.close(() => {
|
|
|
|
logger.info('HTTP server closed.');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
2023-07-30 07:27:00 +00:00
|
|
|
});
|
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
logger.info('Received SIGTERM signal. Shutting down gracefully.');
|
2023-07-30 07:27:00 +00:00
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
server.close(() => {
|
|
|
|
logger.info('HTTP server closed.');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
2023-07-30 07:27:00 +00:00
|
|
|
});
|
|
|
|
|
2023-08-06 06:21:17 +00:00
|
|
|
process.on('unhandledRejection', reason => {
|
|
|
|
logger.error('Unhandled rejection', reason);
|
|
|
|
process.exit(1);
|
2023-07-29 21:50:42 +00:00
|
|
|
});
|