diff options
author | Rich Trott <rtrott@gmail.com> | 2021-10-11 07:55:04 +0300 |
---|---|---|
committer | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2021-10-20 12:59:11 +0300 |
commit | d0b58c0287e67a139137aa906819d95f8314b093 (patch) | |
tree | e9a92870138d89b608b1c6e6568611744c32c4f2 /doc/api/cluster.md | |
parent | a7c17e08de658cbc0beefd8e9583803b5a62ac7e (diff) |
doc: format doc/api/*.md with markdown formatter
PR-URL: https://github.com/nodejs/node/pull/40403
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'doc/api/cluster.md')
-rw-r--r-- | doc/api/cluster.md | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/doc/api/cluster.md b/doc/api/cluster.md index f3e7b9d535a..609a334d979 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -146,6 +146,7 @@ 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` + <!-- YAML added: v0.7.0 --> @@ -157,6 +158,7 @@ In the primary it can be obtained using `cluster.workers`. In a worker it can be obtained using `cluster.worker`. ### Event: `'disconnect'` + <!-- YAML added: v0.7.7 --> @@ -170,6 +172,7 @@ cluster.fork().on('disconnect', () => { ``` ### Event: `'error'` + <!-- YAML added: v0.7.3 --> @@ -179,6 +182,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'` + <!-- YAML added: v0.11.2 --> @@ -220,6 +224,7 @@ worker.on('exit', (code, signal) => { ``` ### Event: `'listening'` + <!-- YAML added: v0.7.0 --> @@ -247,6 +252,7 @@ cluster.fork().on('listening', (address) => { It is not emitted in the worker. ### Event: `'message'` + <!-- YAML added: v0.7.0 --> @@ -351,6 +357,7 @@ if (cluster.isPrimary) { ``` ### Event: `'online'` + <!-- YAML added: v0.7.0 --> @@ -366,6 +373,7 @@ cluster.fork().on('online', () => { It is not emitted in the worker. ### `worker.disconnect()` + <!-- YAML added: v0.7.7 changes: @@ -390,7 +398,7 @@ connections will be allowed to close as usual. When no more connections exist, see [`server.close()`][], the IPC channel to the worker will close allowing it to die gracefully. -The above applies *only* to server connections, client connections are not +The above applies _only_ to server connections, client connections are not automatically closed by workers, and disconnect does not wait for them to close before exiting. @@ -436,6 +444,7 @@ if (cluster.isPrimary) { ``` ### `worker.exitedAfterDisconnect` + <!-- YAML added: v6.0.0 --> @@ -462,6 +471,7 @@ worker.kill(); ``` ### `worker.id` + <!-- YAML added: v0.8.0 --> @@ -475,6 +485,7 @@ While a worker is alive, this is the key that indexes it in `cluster.workers`. ### `worker.isConnected()` + <!-- YAML added: v0.11.14 --> @@ -484,6 +495,7 @@ IPC channel, `false` otherwise. A worker is connected to its primary after it has been created. It is disconnected after the `'disconnect'` event is emitted. ### `worker.isDead()` + <!-- YAML added: v0.11.14 --> @@ -556,6 +568,7 @@ if (cluster.isPrimary) { ``` ### `worker.kill([signal])` + <!-- YAML added: v0.9.12 --> @@ -581,6 +594,7 @@ In a worker, `process.kill()` exists, but it is not this function; it is [`kill()`][]. ### `worker.process` + <!-- YAML added: v0.7.0 --> @@ -598,6 +612,7 @@ on `process` and `.exitedAfterDisconnect` is not `true`. This protects against accidental disconnection. ### `worker.send(message[, sendHandle[, options]][, callback])` + <!-- YAML added: v0.7.0 changes: @@ -640,6 +655,7 @@ if (cluster.isPrimary) { ``` ## Event: `'disconnect'` + <!-- YAML added: v0.7.9 --> @@ -661,6 +677,7 @@ cluster.on('disconnect', (worker) => { ``` ## Event: `'exit'` + <!-- YAML added: v0.7.9 --> @@ -685,6 +702,7 @@ cluster.on('exit', (worker, code, signal) => { See [`child_process` event: `'exit'`][]. ## Event: `'fork'` + <!-- YAML added: v0.7.0 --> @@ -713,6 +731,7 @@ cluster.on('exit', (worker, code, signal) => { ``` ## Event: `'listening'` + <!-- YAML added: v0.7.0 --> @@ -744,6 +763,7 @@ The `addressType` is one of: * `'udp4'` or `'udp6'` (UDP v4 or v6) ## Event: `'message'` + <!-- YAML added: v2.5.0 changes: @@ -761,6 +781,7 @@ Emitted when the cluster primary receives a message from any worker. See [`child_process` event: `'message'`][]. ## Event: `'online'` + <!-- YAML added: v0.7.0 --> @@ -779,6 +800,7 @@ cluster.on('online', (worker) => { ``` ## Event: `'setup'` + <!-- YAML added: v0.7.1 --> @@ -794,6 +816,7 @@ The `settings` object is the `cluster.settings` object at the time If accuracy is important, use `cluster.settings`. ## `cluster.disconnect([callback])` + <!-- YAML added: v0.7.7 --> @@ -812,6 +835,7 @@ finished. This can only be called from the primary process. ## `cluster.fork([env])` + <!-- YAML added: v0.6.0 --> @@ -824,6 +848,7 @@ Spawn a new worker process. This can only be called from the primary process. ## `cluster.isMaster` + <!-- YAML added: v0.8.1 deprecated: v16.0.0 @@ -833,6 +858,7 @@ Deprecated alias for [`cluster.isPrimary`][]. details. ## `cluster.isPrimary` + <!-- YAML added: v16.0.0 --> @@ -844,6 +870,7 @@ by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID` is undefined, then `isPrimary` is `true`. ## `cluster.isWorker` + <!-- YAML added: v0.6.0 --> @@ -853,6 +880,7 @@ added: v0.6.0 True if the process is not a primary (it is the negation of `cluster.isPrimary`). ## `cluster.schedulingPolicy` + <!-- YAML added: v0.11.2 --> @@ -871,6 +899,7 @@ distribute IOCP handles without incurring a large performance hit. values are `'rr'` and `'none'`. ## `cluster.settings` + <!-- YAML added: v0.7.1 changes: @@ -894,10 +923,10 @@ changes: --> * {Object} - * `execArgv` {string[]} List of string arguments passed to the Node.js + * `execArgv` {string\[]} List of string arguments passed to the Node.js executable. **Default:** `process.execArgv`. * `exec` {string} File path to worker file. **Default:** `process.argv[1]`. - * `args` {string[]} String arguments passed to worker. + * `args` {string\[]} String arguments passed to worker. **Default:** `process.argv.slice(2)`. * `cwd` {string} Current working directory of the worker process. **Default:** `undefined` (inherits from parent process). @@ -925,6 +954,7 @@ contain the settings, including the default values. This object is not intended to be changed or set manually. ## `cluster.setupMaster([settings])` + <!-- YAML added: v0.7.1 deprecated: v16.0.0 @@ -937,6 +967,7 @@ changes: Deprecated alias for [`.setupPrimary()`][]. ## `cluster.setupPrimary([settings])` + <!-- YAML added: v16.0.0 --> @@ -990,6 +1021,7 @@ cluster.fork(); // http worker This can only be called from the primary process. ## `cluster.worker` + <!-- YAML added: v0.7.0 --> @@ -1023,6 +1055,7 @@ if (cluster.isPrimary) { ``` ## `cluster.workers` + <!-- YAML added: v0.7.0 --> |