daemonic-inheritance-test.js
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* daemonic-inheritance-test.js: Tests for configuration inheritance of forever.startDaemon()
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
vows = require('vows'),
forever = require('../../lib/forever');
//
// n.b. (indexzero): The default root is `~/.forever` so this
// actually is a valid, non-default test path.
//
var myRoot = path.resolve(process.env.HOME, '.forever_root');
vows.describe('forever/core/startDaemon').addBatch({
"When using forever" : {
"the startDaemon() method with customized configuration" : {
topic: function () {
if (!fs.existsSync(myRoot)) {
fs.mkdirSync(myRoot);
}
forever.load({root:myRoot});
forever.startDaemon(path.join(__dirname, '..', 'fixtures', 'log-on-interval.js'));
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"should respond with 1 process": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
},
"and logs/pids/socks are all piping into the customized root": function (err, procs) {
assert.equal(procs[0].logFile.indexOf(myRoot), 0);
assert.equal(procs[0].pidFile.indexOf(myRoot), 0);
assert.equal(procs[0].socket.indexOf(myRoot), 0);
}
}
}
}).addBatch({
"When the tests are over" : {
"stop all forever processes" : {
topic: function () {
forever.load({root:myRoot});
forever.stopAll().on('stopAll', this.callback.bind(null, null));
},
"should stop the correct number of procs": function (err, procs) {
assert.isArray(procs);
assert.lengthOf(procs, 1);
}
}
}
}).export(module);