Skip to content

Commit

Permalink
[test minor] A couple of small updates for tests after recent API cha…
Browse files Browse the repository at this point in the history
…nges. Readd Worker.exitOnStop
  • Loading branch information
indexzero committed Jan 5, 2012
1 parent 3888dbd commit 1f78240
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ forever.startServer = function () {
async.map(monitors, function (monitor, next) {
var worker = new forever.Worker({
monitor: monitor,
sockPath: forever.config.get('sockPath')
sockPath: forever.config.get('sockPath'),
exitOnStop: true
});

worker.start(function (err) {
Expand Down
1 change: 0 additions & 1 deletion lib/forever/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var fs = require('fs'),
path = require('path'),
util = require('util'),
events = require('events'),
dnode = require('dnode'),
portfinder = require('portfinder'),
forever = require('../../forever'),
SystemVAdapter = require('./adapters/systemv');
Expand Down
4 changes: 2 additions & 2 deletions lib/forever/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var Worker = exports.Worker = function (options) {

this.monitor = options.monitor;
this.sockPath = options.sockPath || forever.config.get('sockPath');
this.exitOnKill = options.exitOnKill === true;
this.exitOnStop = options.exitOnStop === true;

this._socket = null;
};
Expand Down Expand Up @@ -71,7 +71,7 @@ Worker.prototype.start = function (callback) {
socket.data(['stop'], function () {
self.monitor.once('stop', function () {
socket.send(['stop', 'ok']);
process.exit();
self.exitOnStop && process.exit();
});

self.monitor.stop();
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/mocks/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MonitorMock.prototype.__defineGetter__('data', function () {
}
});

MonitorMock.prototype.kill = function (forceStop) {
MonitorMock.prototype.kill = MonitorMock.prototype.stop = function (forceStop) {
this.running = false;

this.emit('stop');
Expand Down
3 changes: 3 additions & 0 deletions test/worker/multiple-workers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ vows.describe('forever/workers/multiple').addBatch({
},
"requests against the first child": assertRunning(8080),
"requests against the second child": assertRunning(8081)
//
// TODO: We should cleanup these processes.
//
}
},
}).export(module);
4 changes: 2 additions & 2 deletions test/worker/simple-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ vows.describe('forever/worker/simple').addBatch({
var self = this;

options.monitor.running = true;
reader.send(['kill']);
reader.data(['kill', 'stop'], function () {
reader.send(['stop']);
reader.data(['stop', 'ok'], function () {
self.callback(null, options.monitor);
});
},
Expand Down

0 comments on commit 1f78240

Please sign in to comment.