Skip to content

Commit

Permalink
[api test] Expose this.spawnWith in Monitor.data
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Oct 9, 2011
1 parent 14c82fd commit 91dbd32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ Monitor.prototype.__defineGetter__('data', function () {
options: this.options.slice(1),
pid: this.child.pid,
silent: this.silent,
uid: this.uid
uid: this.uid,
spawnWith: this.spawnWith
};

['pidFile', 'outFile', 'errFile', 'env', 'cwd'].forEach(function (key) {
Expand Down
19 changes: 17 additions & 2 deletions test/multiple-processes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vows.describe('forever/multiple-processes').addBatch({
"and spawning two processes using the same script": {
topic: function () {
var that = this,
output = ''
script = path.join(__dirname, '..', 'examples', 'server.js');

this.child1 = new (forever.Monitor)(script, {
Expand All @@ -31,11 +32,26 @@ vows.describe('forever/multiple-processes').addBatch({
maxRestart: 1,
options: [ "--port=8081"]
});

function buildJson (data) {
var json;

try {
output += data;
json = JSON.parse(output.toString());
that.callback(null, json);
}
catch (ex) {
//
// Do nothing here
//
}
}

that.child2.on('start', function () {
forever.startServer(that.child1, that.child2, function (err, server, socketPath) {
var socket = new net.Socket();
socket.on('data', that.callback.bind(null, null));
socket.on('data', buildJson);
socket.on('error', that.callback);
socket.connect(socketPath);
});
Expand All @@ -48,7 +64,6 @@ vows.describe('forever/multiple-processes').addBatch({
},
"should spawn both processes appropriately": function (err, data) {
assert.isNull(err);
data = JSON.parse(data.toString());
assert.length(data.monitors, 2);
this.child1.stop();
this.child2.stop();
Expand Down

0 comments on commit 91dbd32

Please sign in to comment.