Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50661 views
1
/*
2
* signal-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/signal').addBatch({
15
"When using forever-monitor": {
16
"and spawning a script that ignores signals SIGINT and SIGTERM": {
17
"with killTTL defined": {
18
topic: function () {
19
var script = path.join(__dirname, '..', '..', 'examples', 'signal-ignore.js'),
20
child = new (fmonitor.Monitor)(script, { silent: true, killTTL: 1000 }),
21
callback = this.callback,
22
timer;
23
24
timer = setTimeout(function () {
25
callback(new Error('Child did not die when killed by forever'), child);
26
}, 3000);
27
28
child.on('exit', function () {
29
callback.apply(null, [null].concat([].slice.call(arguments)));
30
clearTimeout(timer);
31
});
32
33
child.on('start', function () {
34
//
35
// Give it time to set up signal handlers
36
//
37
setTimeout(function() {
38
child.stop();
39
}, 1000);
40
});
41
42
child.start();
43
},
44
"should forcibly kill the processes": function (err, child, spinning) {
45
assert.isNull(err);
46
}
47
}
48
}
49
}
50
}).export(module);
51
52