Skip to content

Commit

Permalink
fix script
Browse files Browse the repository at this point in the history
  • Loading branch information
samchungy authored Oct 28, 2023
1 parent 82937c4 commit f6edda1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
21 changes: 1 addition & 20 deletions template/express-rest-api/src/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,12 @@ const listener = app.listen(config.port, () => {
// AWS recommends setting an application timeout larger than the load balancer
listener.keepAliveTimeout = 31000;

const gracefullyShutdown = () => {
process.on('SIGTERM', () => {
logger.debug('Draining remaining connections');

listener.close(() => {
logger.debug('Remaining connections drained');
// Additional cleanup tasks go here, e.g., close database connection
// eslint-disable-next-line no-process-exit
process.exit(0);
});
};

process.on('SIGTERM', () => {
listener.close(() => {
gracefullyShutdown();
});
});

process.on('SIGTERM', () => {
listener.close(() => {
gracefullyShutdown();
});
});

process.on('SIGINT', () => {
listener.close(() => {
gracefullyShutdown();
});
});
15 changes: 1 addition & 14 deletions template/koa-rest-api/src/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,12 @@ const listener = app.listen(config.port, () => {
// AWS recommends setting an application timeout larger than the load balancer
listener.keepAliveTimeout = 31000;

const gracefullyShutdown = () => {
process.on('SIGTERM', () => {
logger.debug('Draining remaining connections');

listener.close(() => {
logger.debug('Remaining connections drained');
// Additional cleanup tasks go here, e.g., close database connection
// eslint-disable-next-line no-process-exit
process.exit(0);
});
};

process.on('SIGTERM', () => {
listener.close(() => {
gracefullyShutdown();
});
});

process.on('SIGINT', () => {
listener.close(() => {
gracefullyShutdown();
});
});

0 comments on commit f6edda1

Please sign in to comment.