Skip to content

Commit

Permalink
Clarify worker code vs master code and how to get worker id
Browse files Browse the repository at this point in the history
  • Loading branch information
m14t committed Nov 25, 2015
1 parent 6bbd928 commit 5ccdd57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -11,10 +11,11 @@ npm install sticky-session
## Usage

```javascript
var cluster = require('cluster'); // Only required if you want the worker id
var sticky = require('sticky-session');

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

if (!sticky.listen(server, 3000)) {
Expand All @@ -23,7 +24,7 @@ if (!sticky.listen(server, 3000)) {
console.log('server started on 3000 port');
});
} else {
// Master code
// Worker code
}
```
Simple
Expand Down

0 comments on commit 5ccdd57

Please sign in to comment.