2024-07-03 18:52:30 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2024-07-05 19:34:48 +00:00
|
|
|
require('../configs/env.config')('production');
|
2024-07-03 18:52:30 +00:00
|
|
|
const logger = require('../dist/utils/logger.util').default;
|
|
|
|
const App = require('../dist/app').default;
|
|
|
|
const app = new App().app;
|
|
|
|
|
|
|
|
const port = process.env.PORT || 3000;
|
|
|
|
|
|
|
|
const server = app.listen(port, () => {
|
|
|
|
logger.info(`Listening on port ${port}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
const exit = () => {
|
|
|
|
if (server) server.close();
|
|
|
|
logger.info('server close');
|
|
|
|
process.exit(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
const unexpectedError = (error) => {
|
|
|
|
logger.error(error);
|
|
|
|
exit();
|
|
|
|
};
|
|
|
|
|
|
|
|
process.on('uncaughtException', unexpectedError);
|
|
|
|
process.on('unhandledRejection', unexpectedError);
|
|
|
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
logger.info('SIGTERM received');
|
|
|
|
exit();
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = server;
|