From 1f78240ab7d37f5f0be916274e148ec662fab853 Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 5 Jan 2012 05:28:18 -0500 Subject: [PATCH] [test minor] A couple of small updates for tests after recent API changes. Readd Worker.exitOnStop --- lib/forever.js | 3 ++- lib/forever/service/service.js | 1 - lib/forever/worker.js | 4 ++-- test/helpers/mocks/monitor.js | 2 +- test/worker/multiple-workers-test.js | 3 +++ test/worker/simple-test.js | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/forever.js b/lib/forever.js index cfa1f436..620c6351 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -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) { diff --git a/lib/forever/service/service.js b/lib/forever/service/service.js index 74a3e005..017c6c6c 100644 --- a/lib/forever/service/service.js +++ b/lib/forever/service/service.js @@ -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'); diff --git a/lib/forever/worker.js b/lib/forever/worker.js index a7774ce9..bb14026e 100644 --- a/lib/forever/worker.js +++ b/lib/forever/worker.js @@ -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; }; @@ -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(); diff --git a/test/helpers/mocks/monitor.js b/test/helpers/mocks/monitor.js index a46242ac..411780d6 100644 --- a/test/helpers/mocks/monitor.js +++ b/test/helpers/mocks/monitor.js @@ -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'); diff --git a/test/worker/multiple-workers-test.js b/test/worker/multiple-workers-test.js index 5a1c11c4..2a0ad47c 100644 --- a/test/worker/multiple-workers-test.js +++ b/test/worker/multiple-workers-test.js @@ -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); diff --git a/test/worker/simple-test.js b/test/worker/simple-test.js index 27c78b2f..f25417c6 100644 --- a/test/worker/simple-test.js +++ b/test/worker/simple-test.js @@ -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); }); },