Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Graceful shutdown template for Ctrl-C with Windows support
if (process.platform === 'win32') {
require('readline')
.createInterface({
input: process.stdin,
output: process.stdout
})
.on('SIGINT', function () {
process.emit('SIGINT');
});
}
process.on('SIGINT', function () {
// code of graceful shutdown here
process.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment