Skip to content

Commit b6e41b5

Browse files
author
Nicolas Huray
committed
Handle properly SINGINT and SIGTERM signals
1 parent c7a2470 commit b6e41b5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cli.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
#!/usr/bin/env node
22

3+
// Handle signals properly
4+
// see: https://github.com/nodejs/node-v0.x-archive/issues/9131
5+
exitOnSignal('SIGINT');
6+
exitOnSignal('SIGTERM');
7+
8+
function exitOnSignal(signal) {
9+
process.on(signal, function() {
10+
console.log('\ncaught ' + signal + ', exiting');
11+
// perform all required cleanup
12+
process.exit(0);
13+
});
14+
}
15+
316
var argv = require('minimist')(process.argv.slice(2))
417

518
if (argv.help) {

0 commit comments

Comments
 (0)