Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPooya Karimian <pkarimian@sencha.com>2012-08-18 00:57:23 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-09-07 00:00:05 +0400
commit0087bc6370c440fad0d8fc61515a7c02e9f8ae1b (patch)
tree7e943128604ab8d1d8f4067522a8b8f9ceac9a3b /doc
parent052e63f27f7b1edf5635d6a266653fe77c42941c (diff)
cluster.worker description and examples ere missing from the top level of docs
Diffstat (limited to 'doc')
-rw-r--r--doc/api/cluster.markdown19
1 files changed, 18 insertions, 1 deletions
diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown
index aa59acbf48a..032e38138e2 100644
--- a/doc/api/cluster.markdown
+++ b/doc/api/cluster.markdown
@@ -252,12 +252,29 @@ die graceful if no other event is waiting.
The method takes an optional callback argument which will be called when finished.
+## cluster.worker
+
+* {Object}
+
+A reference to the current worker object. Not available in the master process.
+
+ var cluster = require('cluster');
+
+ if (cluster.isMaster) {
+ console.log('I am master');
+ cluster.fork();
+ cluster.fork();
+ } else if (cluster.isWorker) {
+ console.log('I am worker #' + cluster.worker.id);
+ }
+
## cluster.workers
* {Object}
A hash that stores the active worker objects, keyed by `id` field. Makes it
-easy to loop through all the workers.
+easy to loop through all the workers. It is only available in the master
+process.
// Go through all workers
function eachWorker(callback) {