fix: shutdown server on SIGTERM

This commit is contained in:
Ali BARIN
2022-09-26 21:42:22 +02:00
parent 93b31c10ae
commit dd003845af

View File

@@ -1,3 +1,4 @@
import type { Server } from 'http';
import app from './app';
import appConfig from './config/app';
import logger from './helpers/logger';
@@ -7,6 +8,14 @@ telemetry.setServiceType('main');
const port = appConfig.port;
app.listen(port, () => {
const server: Server = app.listen(port, () => {
logger.info(`Server is listening on ${port}`);
});
function shutdown(server: Server) {
server.close();
}
process.on('SIGTERM', () => {
shutdown(server);
});