Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli 'restart' with .in().listen().in().listen() prevents workers from respawning #150

Open
nibblebot opened this issue Sep 19, 2011 · 0 comments

Comments

@nibblebot
Copy link
Contributor

similar to #149, but i realize I'm still experiencing the issue that is most critical

var path = require('path');
var cluster = require('cluster');
cluster(require('http').createServer())
  .use(cluster.pidfiles())
    .use(cluster.cli())
    .in('development').listen(3000)
    .in('staging').listen(3020)

~/code/cluster_test node server status

master 32251 alive
worker 0 32252 alive
worker 1 32253 alive
worker 2 32254 alive
worker 3 32255 alive
worker 4 32256 alive
worker 5 32257 alive
worker 6 32258 alive
worker 7 32259 alive

~/code/cluster_test node server restart

~/code/cluster_test node server status

master 32266 alive
worker 0 32252 dead
worker 1 32253 dead
worker 2 32254 dead
worker 3 32255 dead
worker 4 32256 dead
worker 5 32257 dead
worker 6 32258 dead
worker 7 32259 dead

If I comment out the second .in() it works as expected.

var path = require('path');
var cluster = require('cluster');
cluster(require('http').createServer())
  .use(cluster.pidfiles())
    .use(cluster.cli())
    .in('development').listen(3000)
    //.in('staging').listen(3020)

~/code/cluster_test node server status

master 32297 alive
worker 0 32298 alive
worker 1 32299 alive
worker 2 32300 alive
worker 3 32301 alive
worker 4 32302 alive
worker 5 32303 alive
worker 6 32304 alive
worker 7 32305 alive

[02:10 PM] josh@nyl2060n
~/code/cluster_test node server restart

[02:10 PM] josh@nyl2060n
~/code/cluster_test node server status

master 32331 alive
worker 0 32332 alive
worker 1 32333 alive
worker 2 32334 alive
worker 3 32335 alive
worker 4 32336 alive
worker 5 32337 alive
worker 6 32338 alive
worker 7 32339 alive

I am unable to discover why this is. I know that process.kill() doesn't throw an error.

I added some code to tap into all the events master emits:

var path = require('path');
var cluster = require(path.join(__dirname+'/../cluster'));
var master = cluster(require('http').createServer());
['start', 'worker', 'listening', 'closing', 'close', 'worker killed', 'worker exception', 'worker removed', 'kill', 'restarting', 'restart'].forEach(function(event) {
    master.on(event, function(){ console.log(event); });
});
master
  .use(cluster.pidfiles())
    .use(cluster.cli())
    .in('development').listen(3000)
    .in('staging').listen(3020)

here is working start/restart sequence:
start
worker
worker
worker
worker
worker
worker
worker
worker
listening
$ node server restart
restarting
start
worker
worker
worker
worker
worker
worker
worker
worker
listening
closing
kill
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
close
restart

here is failing start/restart sequence:

start
worker
worker
worker
worker
worker
worker
worker
worker
listening
$ node server restart
restarting
start
listening
closing
kill
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
worker killed
close
restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant