Skip to content

Commit

Permalink
Handle properly SINGINT and SIGTERM signals
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Huray committed Feb 2, 2017
1 parent c7a2470 commit b6e41b5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/usr/bin/env node

// Handle signals properly
// see: https://github.com/nodejs/node-v0.x-archive/issues/9131
exitOnSignal('SIGINT');
exitOnSignal('SIGTERM');

function exitOnSignal(signal) {
process.on(signal, function() {
console.log('\ncaught ' + signal + ', exiting');
// perform all required cleanup
process.exit(0);
});
}

var argv = require('minimist')(process.argv.slice(2))

if (argv.help) {
Expand Down

0 comments on commit b6e41b5

Please sign in to comment.