-
Notifications
You must be signed in to change notification settings - Fork 178
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
1 parent
771ea22
commit 9ae718b
Showing
3 changed files
with
63 additions
and
1 deletion.
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,3 @@ | ||
setTimeout(function (){ | ||
process.exit(0); | ||
}, 1000); |
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,57 @@ | ||
/* | ||
* neglect-clean-exit-test.js: Tests for spin restarts in forever. | ||
* | ||
* (C) 2010 Charlie Robbins & the Contributors | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
path = require('path'), | ||
vows = require('vows'), | ||
fmonitor = require('../../lib'); | ||
|
||
vows.describe('forever-monitor/monitor/neglect-clean-exit').addBatch({ | ||
"When using forever-monitor": { | ||
"and spawning a script that exits gracefully": { | ||
"with neglectCleanExit enabled": { | ||
topic: function () { | ||
var script = path.join(__dirname, '..', '..', 'examples', 'graceful-exit-automatically.js'), | ||
child = new (fmonitor.Monitor)(script, { neglectCleanExit: true }); | ||
|
||
child.on('exit', this.callback); | ||
child.start(); | ||
}, | ||
"should not restart script": function (child, spinning) { | ||
assert.isFalse(child.running); | ||
}, | ||
}, | ||
"with a neglectCleanExit disabled": { | ||
topic: function () { | ||
var script = path.join(__dirname, '..', '..', 'examples', 'graceful-exit-automatically.js'), | ||
child = new (fmonitor.Monitor)(script, { neglectCleanExit: false }); | ||
|
||
child.on('start', this.callback); | ||
child.start(); | ||
}, | ||
"should restart script": function (child, data) { | ||
assert.isTrue(child.running); | ||
} | ||
} | ||
}, | ||
"and spawning a script that exits with uncaughtException": { | ||
"with a neglectCleanExit enabled": { | ||
topic: function () { | ||
var script = path.join(__dirname, '..', '..', 'examples', 'always-throw.js'), | ||
child = new (fmonitor.Monitor)(script, { neglectCleanExit: true, silent: true }); | ||
|
||
child.on('start', this.callback); | ||
child.start(); | ||
}, | ||
"should restart script": function (child, data) { | ||
assert.isTrue(child.running); | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); |