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

About the example code #35

Open
Pana opened this issue Oct 27, 2015 · 4 comments
Open

About the example code #35

Pana opened this issue Oct 27, 2015 · 4 comments

Comments

@Pana
Copy link

Pana commented Oct 27, 2015

var sticky = require('sticky-session');

var server = require('http').createServer(function(req, res) {
  res.end('worker: ' + process.env.NODE_WORKER_ID);
});

if (!sticky.listen(server, 3000)) {
  // Master code
  server.once('listening', function() {
    console.log('server started on 3000 port');
  });
} else {
  // Master code
}

I think the else code should be worker code, and process.env.NODE_WORKER_ID is undefined in my node 4.0 version

@indutny
Copy link
Owner

indutny commented Oct 27, 2015

Argh, it should be NODE_UNIQUE_ID for the 4.x. May I ask you to file a Pull Request for this change?

@indutny
Copy link
Owner

indutny commented Oct 27, 2015

Thanks!

@Pana
Copy link
Author

Pana commented Oct 28, 2015

When i use the NODE_UNIQUE_ID still got undefined, but i have find this in node cluster doc

True if the process is a master. This is determined by the process.env.NODE_UNIQUE_ID. If process.env.NODE_UNIQUE_ID is undefined, then isMaster is true.

@melv-n
Copy link

melv-n commented Jun 18, 2016

I believe it would be very useful to include an actual socket listener in the README Worker-example. @indutny

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

3 participants