Skip to content

Commit

Permalink
Merge pull request #45 from sbader/reload_bugfix
Browse files Browse the repository at this point in the history
Fixing reload to no longer send requests to old workers
  • Loading branch information
rauchg committed Sep 16, 2012
2 parents 8cfbe08 + c55ad57 commit 15e82c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ UpServer.prototype.spawnWorker = function (fn) {
self.emit('spawn', w);
break;

case 'terminating':
case 'terminated':
if (~self.spawning.indexOf(w)) {
self.spawning.splice(self.spawning.indexOf(w), 1);
Expand Down
24 changes: 18 additions & 6 deletions test/up.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,26 @@ describe('up', function () {

srv.once('spawn', function () {
request.get('http://localhost:6002', function (res) {
expect(res.body.pid).to.not.equal(pid1);
pid1 = res.body.pid;
var pid3 = res.body.pid;
expect(pid3).to.not.equal(pid1);
expect(pid3).to.not.equal(pid2);

request.get('http://localhost:6002', function (res) {
expect(res.body.pid).to.not.equal(pid1);
expect(res.body.pid).to.not.equal(pid2);
expect(reloadFired).to.be(true);
done();
var pid4 = res.body.pid;
expect(pid4).to.not.equal(pid1);
expect(pid4).to.not.equal(pid2);
expect(pid4).to.not.equal(pid3);

request.get('http://localhost:6002', function (res) {
// confirm that the initial workers are not used when the
// server gets back to the start of the list
var pid5 = res.body.pid;
expect(pid5).to.not.equal(pid1);
expect(pid5).to.not.equal(pid2);

expect(reloadFired).to.be(true);
done();
});
});
});
});
Expand Down

0 comments on commit 15e82c6

Please sign in to comment.