Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
  • Loading branch information
fredmaiaarantes committed Dec 6, 2023
2 parents 33987eb + d79afd9 commit 4ea7a44
Show file tree
Hide file tree
Showing 4 changed files with 6,691 additions and 4,272 deletions.
2 changes: 2 additions & 0 deletions api/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Migrations } from 'meteor/percolate:migrations';

import './shutdown-handler';
import './db/migrations';
import './tasks/tasks.publications';
import './tasks/tasks.methods';
Expand Down
25 changes: 25 additions & 0 deletions api/shutdown-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meteor } from 'meteor/meteor';
import { DDPGracefulShutdown } from '@meteorjs/ddp-graceful-shutdown';

class SimpleDDPGracefulShutdown extends DDPGracefulShutdown {
installSIGTERMHandler() {
process.on(
'SIGTERM',
Meteor.bindEnvironment(() => {
const gracePeriod =
process.env.METEOR_SIGTERM_GRACE_PERIOD_SECONDS || 30;
// eslint-disable-next-line no-console
console.log(
`Received SIGTERM. Shutting down in ${gracePeriod} seconds.`
);

this.closeConnections({ log: true });
})
);
}
}

new SimpleDDPGracefulShutdown({
gracePeriodMillis: 1000 * process.env.METEOR_SIGTERM_GRACE_PERIOD_SECONDS,
server: Meteor.server,
}).installSIGTERMHandler();
Loading

0 comments on commit 4ea7a44

Please sign in to comment.