Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
/*
2
* tail-stopall-test.js: Tests for forever.tail() and forever.stopAll()
3
*
4
* (C) 2010 Nodejitsu Inc.
5
* MIT LICENCE
6
*
7
*/
8
9
var assert = require('assert'),
10
path = require('path'),
11
spawn = require('child_process').spawn,
12
vows = require('vows'),
13
forever = require('../../lib/forever');
14
15
vows.describe('forever/core/tail').addBatch({
16
"When using forever": {
17
"the tail() method": {
18
topic: function () {
19
var that = this;
20
21
that.child = spawn('node', [path.join(__dirname, '..', 'fixtures', 'start-daemon.js')]);
22
setTimeout(function () {
23
forever.tail(0, that.callback);
24
}, 2000);
25
},
26
"should respond with logs for the script": function (err, procs) {
27
assert.isNull(err);
28
assert.isArray(procs);
29
procs.forEach(function (proc) {
30
assert.isArray(proc.logs);
31
assert.isTrue(!!proc.logs.length);
32
assert.isTrue(proc.logs.length > 10);
33
// Temporary hack, remove after warnings are gone.
34
proc.logs = proc.logs.slice(1);
35
proc.logs.forEach(function (line) {
36
assert.match(line, /^Logging at/);
37
});
38
});
39
}
40
}
41
}
42
}).addBatch({
43
"When the tests are over": {
44
"stop all forever processes": {
45
topic: function () {
46
forever.stopAll().on('stopAll', this.callback.bind(null, null));
47
},
48
"should stop the correct number of procs": function (err, procs) {
49
assert.isArray(procs);
50
assert.lengthOf(procs, 1);
51
}
52
}
53
}
54
}).export(module);
55
56