-
Notifications
You must be signed in to change notification settings - Fork 944
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] give sigkills after a timeout given by options.killTTL in MS
- Loading branch information
Showing
4 changed files
with
103 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function noop() { | ||
console.log('IGNORED!') | ||
} | ||
process.on('SIGTERM',noop); | ||
process.on('SIGINT',noop); | ||
setInterval(function(){ | ||
console.log('heartbeat'); | ||
}, 100); |
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
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
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,50 @@ | ||
/* | ||
* signal-test.js: Tests for spin restarts in forever. | ||
* | ||
* (C) 2010 Nodejitsu Inc. | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
path = require('path'), | ||
vows = require('vows'), | ||
forever = require('../lib/forever'); | ||
|
||
vows.describe('forever/signal').addBatch({ | ||
"When using forever": { | ||
"and spawning a script that ignores signals SIGINT and SIGTERM": { | ||
"with killTTL defined": { | ||
topic: function () { | ||
var script = path.join(__dirname, '..', 'examples', 'signal-ignore.js'), | ||
child = new (forever.Monitor)(script, { silent: true, killTTL: 1000 }), | ||
callback = this.callback, | ||
timer; | ||
|
||
timer = setTimeout(function () { | ||
callback(new Error('Child did not die when killed by forever'), child); | ||
}, 3000); | ||
|
||
child.on('exit', function () { | ||
callback.apply(null, [null].concat([].slice.call(arguments))); | ||
clearTimeout(timer); | ||
}); | ||
|
||
child.on('start', function () { | ||
// | ||
// Give it time to set up signal handlers | ||
// | ||
setTimeout(function() { | ||
child.stop(); | ||
}, 1000); | ||
}); | ||
|
||
child.start(); | ||
}, | ||
"should forcibly kill the processes": function (err, child, spinning) { | ||
assert.isNull(err); | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); |