forked from remy/nodemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ node_js: | |
- "0.11" | ||
- "0.10" | ||
- "0.8" | ||
- "0.6" | ||
before_script: | ||
- npm install | ||
notifications: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var utils = require('./utils'), | ||
config = require('./config'); | ||
|
||
// does not export anything, only listens for events | ||
module.exports = {}; | ||
|
||
// remove the flag file on exit | ||
process.on('exit', function (code) { | ||
if (config.options.verbose) { | ||
utils.log.status('exiting'); | ||
} | ||
cleanup(); | ||
}); | ||
|
||
// because windows borks when listening for the SIG* events | ||
if (!utils.isWindows) { | ||
// usual suspect: ctrl+c exit | ||
process.on('SIGINT', function () { | ||
var exitTimeout = null, | ||
exit = function () { | ||
exit = function () {}; | ||
cleanup(); | ||
process.exit(0); | ||
}; | ||
|
||
if (child && !isWindows) { | ||
child.removeAllListeners('exit'); | ||
child.on('exit', exit); | ||
child.kill('SIGINT'); | ||
setTimeout(exit, 10 * 1000); // give up waiting for the kids after 10 seconds | ||
} else { | ||
exit(); | ||
} | ||
}); | ||
|
||
process.on('SIGTERM', function () { | ||
cleanup(); | ||
process.exit(0); | ||
}); | ||
} | ||
|
||
// on exception *inside* nodemon, shutdown wrapped node app | ||
process.on('uncaughtException', function (err) { | ||
util.log('[nodemon] exception in nodemon killing node'); | ||
util.error(err.stack); | ||
cleanup(); | ||
}); |