Terminating the instance via Ctrl+C or killing the node process usually leaves a residue of temporary files. In order to have a clean shutdown, we should watch for process exit signals and handle them gracefully.
// Using a single function to handle multiple signals
function handle(signal) {
console.log('Received signal. Press Control-D to exit.');
process.exit()
}
process.on('SIGINT', handle);
process.on('SIGTERM', handle);
process.on('SIGHUP', handle);
});
Terminating the instance via Ctrl+C or killing the node process usually leaves a residue of temporary files. In order to have a clean shutdown, we should watch for process exit signals and handle them gracefully.
From the docs: