diff --git a/doc/api/cluster.md b/doc/api/cluster.md index a535f8296133f5..a1eb0859c87d8f 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -111,7 +111,7 @@ responsibility to manage the worker pool based on its own needs. Although a primary use case for the `cluster` module is networking, it can also be used for other use cases requiring worker processes. -## Class: Worker +## Class: `Worker` @@ -122,7 +122,7 @@ A `Worker` object contains all public information and method about a worker. In the master it can be obtained using `cluster.workers`. In a worker it can be obtained using `cluster.worker`. -### Event: 'disconnect' +### Event: `'disconnect'` @@ -135,7 +135,7 @@ cluster.fork().on('disconnect', () => { }); ``` -### Event: 'error' +### Event: `'error'` @@ -144,7 +144,7 @@ This event is the same as the one provided by [`child_process.fork()`][]. Within a worker, `process.on('error')` may also be used. -### Event: 'exit' +### Event: `'exit'` @@ -168,7 +168,7 @@ worker.on('exit', (code, signal) => { }); ``` -### Event: 'listening' +### Event: `'listening'` @@ -185,7 +185,7 @@ cluster.fork().on('listening', (address) => { It is not emitted in the worker. -### Event: 'message' +### Event: `'message'` @@ -244,7 +244,7 @@ if (cluster.isMaster) { } ``` -### Event: 'online' +### Event: `'online'` @@ -259,7 +259,7 @@ cluster.fork().on('online', () => { It is not emitted in the worker. -### worker.disconnect() +### `worker.disconnect()` @@ -355,7 +355,7 @@ cluster.on('exit', (worker, code, signal) => { worker.kill(); ``` -### worker.id +### `worker.id` @@ -368,7 +368,7 @@ Each new worker is given its own unique id, this id is stored in the While a worker is alive, this is the key that indexes it in `cluster.workers`. -### worker.isConnected() +### `worker.isConnected()` @@ -377,7 +377,7 @@ This function returns `true` if the worker is connected to its master via its IPC channel, `false` otherwise. A worker is connected to its master after it has been created. It is disconnected after the `'disconnect'` event is emitted. -### worker.isDead() +### `worker.isDead()` @@ -415,7 +415,7 @@ if (cluster.isMaster) { } ``` -### worker.kill(\[signal='SIGTERM'\]) +### `worker.kill([signal='SIGTERM'])` @@ -439,7 +439,7 @@ This method is aliased as `worker.destroy()` for backwards compatibility. In a worker, `process.kill()` exists, but it is not this function; it is [`kill()`][]. -### worker.process +### `worker.process` @@ -456,7 +456,7 @@ Workers will call `process.exit(0)` if the `'disconnect'` event occurs on `process` and `.exitedAfterDisconnect` is not `true`. This protects against accidental disconnection. -### worker.send(message\[, sendHandle\[, options\]\]\[, callback\]) +### `worker.send(message[, sendHandle[, options]][, callback])` @@ -519,7 +519,7 @@ cluster.on('disconnect', (worker) => { }); ``` -## Event: 'exit' +## Event: `'exit'` @@ -543,7 +543,7 @@ cluster.on('exit', (worker, code, signal) => { See [`child_process` event: `'exit'`][]. -## Event: 'fork' +## Event: `'fork'` @@ -571,7 +571,7 @@ cluster.on('exit', (worker, code, signal) => { }); ``` -## Event: 'listening' +## Event: `'listening'` @@ -602,7 +602,7 @@ The `addressType` is one of: * `-1` (Unix domain socket) * `'udp4'` or `'udp6'` (UDP v4 or v6) -## Event: 'message' +## Event: `'message'` @@ -637,7 +637,7 @@ cluster.on('online', (worker) => { }); ``` -## Event: 'setup' +## Event: `'setup'` @@ -652,7 +652,7 @@ The `settings` object is the `cluster.settings` object at the time If accuracy is important, use `cluster.settings`. -## cluster.disconnect(\[callback\]) +## `cluster.disconnect([callback])` @@ -670,7 +670,7 @@ finished. This can only be called from the master process. -## cluster.fork(\[env\]) +## `cluster.fork([env])` @@ -682,7 +682,7 @@ Spawn a new worker process. This can only be called from the master process. -## cluster.isMaster +## `cluster.isMaster` @@ -693,7 +693,7 @@ 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`. -## cluster.isWorker +## `cluster.isWorker` @@ -702,7 +702,7 @@ added: v0.6.0 True if the process is not a master (it is the negation of `cluster.isMaster`). -## cluster.schedulingPolicy +## `cluster.schedulingPolicy` @@ -720,7 +720,7 @@ distribute IOCP handles without incurring a large performance hit. `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`. -## cluster.settings +## `cluster.settings` @@ -833,7 +833,7 @@ if (cluster.isMaster) { } ``` -## cluster.workers +## `cluster.workers`