Handle SIGTERM Async Cleanup
NodeJS
Hard
4 views
Problem Description
Handle SIGTERM, wait for cleanup promise, then exit.
Output Format
Print message then exit.
Constraints
Simulate cleanup with delay.
Official Solution
function delay(ms) {
return new Promise((r) => setTimeout(r, ms));
}
process.on('SIGTERM', async () => {
console.log('meetcode stopping');
await delay(50);
process.exit(0);
});
setInterval(() => {}, 1000);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!