Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed restart race-condition. Closes #125

  • Loading branch information...
commit eed4d3671de1f3b2d287ef21f1f8facbfb87630a 1 parent d55c350
@tj tj authored
Showing with 10 additions and 3 deletions.
  1. +10 −2 lib/master.js
  2. +0 −1  test/test.standalone.restart.js
View
12 lib/master.js
@@ -153,6 +153,7 @@ var Master = module.exports = function Master(server) {
// spawn our workers
this.on('listening', function(){
self.spawn(self.options.workers);
+ self.listening = true;
});
// kill children on master exception
@@ -720,9 +721,16 @@ Master.prototype.spawnMaster = function(){
Master.prototype.connectMaster = function(sig){
var self = this;
- this.on('listening', function(){
+
+ function kill(){
process.kill(self.ppid, sig);
- });
+ }
+
+ if (this.listening) {
+ kill();
+ } else {
+ this.on('listening', kill);
+ }
};
/**
View
1  test/test.standalone.restart.js
@@ -11,7 +11,6 @@ var assert = require('assert');
cluster = cluster()
.set('workers', 2)
.set('restart threshold', 0)
- .use(cluster.debug())
.start();
if (!cluster.isMaster) return;
Please sign in to comment.
Something went wrong with that request. Please try again.