Skip to content
Browse files

[api test] Expose `this.spawnWith` in Monitor.data

  • Loading branch information...
1 parent 14c82fd commit 91dbd32dc95cc0d043d288a0bccda6d894b888bb @indexzero committed Oct 8, 2011
Showing with 19 additions and 3 deletions.
  1. +2 −1 lib/forever/monitor.js
  2. +17 −2 test/multiple-processes-test.js
View
3 lib/forever/monitor.js
@@ -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) {
View
19 test/multiple-processes-test.js
@@ -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, {
@@ -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);
});
@@ -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();

0 comments on commit 91dbd32

Please sign in to comment.
Something went wrong with that request. Please try again.