'Is it necessary to call process.exit() after handling a SIGTERM event in Node.js?
In Node.js it's possible to respond to SIGTERM signal events.
From the official documentation:
function handle(signal) {
console.log(`Received ${signal}`);
}
process.on('SIGTERM', handle);
Is it necessary or advisable to terminate the process with process.exit() in the event handler?
For example:
async function closeGracefully() {
await closeDbConnection();
await stopApplication();
process.exit();
}
process.on('SIGTERM', closeGracefully);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
