Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
/*
2
* spin-test.js: Tests for spin restarts in forever.
3
*
4
* (C) 2010 Nodejitsu Inc.
5
* MIT LICENCE
6
*
7
*/
8
9
var assert = require('assert'),
10
path = require('path'),
11
vows = require('vows'),
12
fmonitor = require('../../lib');
13
14
vows.describe('forever-monitor/monitor/spin-restart').addBatch({
15
"When using forever-monitor": {
16
"and spawning a script that spin restarts": {
17
"with no spinSleepTime specified": {
18
topic: function () {
19
var script = path.join(__dirname, '..', '..', 'examples', 'always-throw.js'),
20
child = new (fmonitor.Monitor)(script, { silent: true, minUptime: 2000, max: 3 });
21
22
child.on('exit', this.callback.bind({}, null));
23
child.start();
24
},
25
"should spawn both processes appropriately": function (err, child, spinning) {
26
assert.isTrue(spinning);
27
},
28
"should only run the bad process once": function (err, child, spinning) {
29
assert.equal(child.times, 1);
30
}
31
},
32
"with a spinSleepTime specified": {
33
topic: function () {
34
var script = path.join(__dirname, '..', '..', 'examples', 'always-throw.js'),
35
child = new (fmonitor.Monitor)(script, { silent: true, max: 3, spinSleepTime: 1 });
36
37
child.on('exit', this.callback.bind({}, null));
38
child.start();
39
},
40
"should restart spinning processes": function (err, child, spinning) {
41
assert.equal(child.times, 3);
42
}
43
}
44
}
45
}
46
}).export(module);
47
48