@@ -108,12 +108,18 @@ responsibility to manage the worker pool for your application's needs.
108108
109109
110110## Class: Worker
111+ <!-- YAML
112+ added: v0.7.0
113+ -->
111114
112115A Worker object contains all public information and method about a worker.
113116In the master it can be obtained using ` cluster.workers ` . In a worker
114117it can be obtained using ` cluster.worker ` .
115118
116119### Event: 'disconnect'
120+ <!-- YAML
121+ added: v0.7.7
122+ -->
117123
118124Similar to the ` cluster.on('disconnect') ` event, but specific to this worker.
119125
@@ -124,12 +130,18 @@ cluster.fork().on('disconnect', () => {
124130```
125131
126132### Event: 'error'
133+ <!-- YAML
134+ added: v0.7.3
135+ -->
127136
128137This event is the same as the one provided by [ ` child_process.fork() ` ] [ ] .
129138
130139In a worker you can also use ` process.on('error') ` .
131140
132141### Event: 'exit'
142+ <!-- YAML
143+ added: v0.11.2
144+ -->
133145
134146* ` code ` {Number} the exit code, if it exited normally.
135147* ` signal ` {String} the name of the signal (eg. ` 'SIGHUP' ` ) that caused
@@ -151,6 +163,9 @@ worker.on('exit', (code, signal) => {
151163```
152164
153165### Event: 'listening'
166+ <!-- YAML
167+ added: v0.7.0
168+ -->
154169
155170* ` address ` {Object}
156171
@@ -165,6 +180,9 @@ cluster.fork().on('listening', (address) => {
165180It is not emitted in the worker.
166181
167182### Event: 'message'
183+ <!-- YAML
184+ added: v0.7.0
185+ -->
168186
169187* ` message ` {Object}
170188* ` handle ` {undefined|Object}
@@ -220,6 +238,9 @@ if (cluster.isMaster) {
220238```
221239
222240### Event: 'online'
241+ <!-- YAML
242+ added: v0.7.0
243+ -->
223244
224245Similar to the ` cluster.on('online') ` event, but specific to this worker.
225246
@@ -232,6 +253,9 @@ cluster.fork().on('online', () => {
232253It is not emitted in the worker.
233254
234255### worker.disconnect()
256+ <!-- YAML
257+ added: v0.7.7
258+ -->
235259
236260In a worker, this function will close all servers, wait for the ` 'close' ` event on
237261those servers, and then disconnect the IPC channel.
@@ -293,6 +317,9 @@ if (cluster.isMaster) {
293317```
294318
295319### worker.exitedAfterDisconnect
320+ <!-- YAML
321+ added: v6.0.0
322+ -->
296323
297324* {Boolean}
298325
@@ -314,6 +341,9 @@ worker.kill();
314341```
315342
316343### worker.id
344+ <!-- YAML
345+ added: v0.8.0
346+ -->
317347
318348* {Number}
319349
@@ -324,17 +354,26 @@ While a worker is alive, this is the key that indexes it in
324354cluster.workers
325355
326356### worker.isConnected()
357+ <!-- YAML
358+ added: v0.11.14
359+ -->
327360
328361This function returns ` true ` if the worker is connected to its master via its IPC
329362channel, ` false ` otherwise. A worker is connected to its master after it's been
330363created. It is disconnected after the ` 'disconnect' ` event is emitted.
331364
332365### worker.isDead()
366+ <!-- YAML
367+ added: v0.11.14
368+ -->
333369
334370This function returns ` true ` if the worker's process has terminated (either
335371because of exiting or being signaled). Otherwise, it returns ` false ` .
336372
337373### worker.kill([ signal='SIGTERM'] )
374+ <!-- YAML
375+ added: v0.9.12
376+ -->
338377
339378* ` signal ` {String} Name of the kill signal to send to the worker
340379 process.
@@ -351,6 +390,9 @@ Note that in a worker, `process.kill()` exists, but it is not this function,
351390it is [ ` kill ` ] [ ] .
352391
353392### worker.process
393+ <!-- YAML
394+ added: v0.7.0
395+ -->
354396
355397* {ChildProcess}
356398
@@ -365,6 +407,9 @@ on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
365407accidental disconnection.
366408
367409### worker.send(message[ , sendHandle] [ , callback ] )
410+ <!-- YAML
411+ added: v0.7.0
412+ -->
368413
369414* ` message ` {Object}
370415* ` sendHandle ` {Handle}
@@ -394,6 +439,10 @@ if (cluster.isMaster) {
394439```
395440
396441### worker.suicide
442+ <!-- YAML
443+ added: v0.7.0
444+ deprecated: v6.0.0
445+ -->
397446
398447> Stability: 0 - Deprecated: Use [ ` worker.exitedAfterDisconnect ` ] [ ] instead.
399448
@@ -420,6 +469,9 @@ This API only exists for backwards compatibility and will be removed in the
420469future.
421470
422471## Event: 'disconnect'
472+ <!-- YAML
473+ added: v0.7.9
474+ -->
423475
424476* ` worker ` {cluster.Worker}
425477
@@ -438,6 +490,9 @@ cluster.on('disconnect', (worker) => {
438490```
439491
440492## Event: 'exit'
493+ <!-- YAML
494+ added: v0.7.9
495+ -->
441496
442497* ` worker ` {cluster.Worker}
443498* ` code ` {Number} the exit code, if it exited normally.
@@ -459,6 +514,9 @@ cluster.on('exit', (worker, code, signal) => {
459514See [ child_process event: 'exit'] [ ] .
460515
461516## Event: 'fork'
517+ <!-- YAML
518+ added: v0.7.0
519+ -->
462520
463521* ` worker ` {cluster.Worker}
464522
@@ -484,6 +542,9 @@ cluster.on('exit', (worker, code, signal) => {
484542```
485543
486544## Event: 'listening'
545+ <!-- YAML
546+ added: v0.7.0
547+ -->
487548
488549* ` worker ` {cluster.Worker}
489550* ` address ` {Object}
@@ -538,6 +599,9 @@ cluster.on('message', function(worker, message, handle) {
538599```
539600
540601## Event: 'online'
602+ <!-- YAML
603+ added: v0.7.0
604+ -->
541605
542606* ` worker ` {cluster.Worker}
543607
@@ -553,6 +617,9 @@ cluster.on('online', (worker) => {
553617```
554618
555619## Event: 'setup'
620+ <!-- YAML
621+ added: v0.7.1
622+ -->
556623
557624* ` settings ` {Object}
558625
@@ -565,6 +632,9 @@ The `settings` object is the `cluster.settings` object at the time
565632If accuracy is important, use ` cluster.settings ` .
566633
567634## cluster.disconnect([ callback] )
635+ <!-- YAML
636+ added: v0.7.7
637+ -->
568638
569639* ` callback ` {Function} called when all workers are disconnected and handles are
570640 closed
@@ -579,6 +649,9 @@ The method takes an optional callback argument which will be called when finishe
579649This can only be called from the master process.
580650
581651## cluster.fork([ env] )
652+ <!-- YAML
653+ added: v0.6.0
654+ -->
582655
583656* ` env ` {Object} Key/value pairs to add to worker process environment.
584657* return {cluster.Worker}
@@ -588,6 +661,9 @@ Spawn a new worker process.
588661This can only be called from the master process.
589662
590663## cluster.isMaster
664+ <!-- YAML
665+ added: v0.8.1
666+ -->
591667
592668* {Boolean}
593669
@@ -596,12 +672,18 @@ by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID` is
596672undefined, then ` isMaster ` is ` true ` .
597673
598674## cluster.isWorker
675+ <!-- YAML
676+ added: v0.6.0
677+ -->
599678
600679* {Boolean}
601680
602681True if the process is not a master (it is the negation of ` cluster.isMaster ` ).
603682
604683## cluster.schedulingPolicy
684+ <!-- YAML
685+ added: v0.11.2
686+ -->
605687
606688The scheduling policy, either ` cluster.SCHED_RR ` for round-robin or
607689` cluster.SCHED_NONE ` to leave it to the operating system. This is a
@@ -617,6 +699,9 @@ distribute IOCP handles without incurring a large performance hit.
617699values are ` "rr" ` and ` "none" ` .
618700
619701## cluster.settings
702+ <!-- YAML
703+ added: v0.7.1
704+ -->
620705
621706* {Object}
622707 * ` execArgv ` {Array} list of string arguments passed to the Node.js
@@ -638,6 +723,9 @@ the settings, including the default values.
638723This object is not supposed to be changed or set manually, by you.
639724
640725## cluster.setupMaster([ settings] )
726+ <!-- YAML
727+ added: v0.7.1
728+ -->
641729
642730* ` settings ` {Object}
643731 * ` exec ` {String} file path to worker file. (Default=` process.argv[1] ` )
@@ -680,6 +768,9 @@ cluster.fork(); // http worker
680768This can only be called from the master process.
681769
682770## cluster.worker
771+ <!-- YAML
772+ added: v0.7.0
773+ -->
683774
684775* {Object}
685776
@@ -698,6 +789,9 @@ if (cluster.isMaster) {
698789```
699790
700791## cluster.workers
792+ <!-- YAML
793+ added: v0.7.0
794+ -->
701795
702796* {Object}
703797
0 commit comments