Skip to content

Instantly share code, notes, and snippets.

@astur
Created April 29, 2016 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astur/915412dec4ad8ee1c17ffeb5644e92e5 to your computer and use it in GitHub Desktop.
Save astur/915412dec4ad8ee1c17ffeb5644e92e5 to your computer and use it in GitHub Desktop.
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