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