mirror of https://github.com/nodejs/node.git
doc: move numCPUs require to top of file in cluster CJS example
PR-URL: https://github.com/nodejs/node/pull/53932 Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>pull/54115/head
parent
890760b8e5
commit
027710e408
|
@ -317,6 +317,7 @@ if (cluster.isPrimary) {
|
|||
```cjs
|
||||
const cluster = require('node:cluster');
|
||||
const http = require('node:http');
|
||||
const numCPUs = require('node:os').availableParallelism();
|
||||
const process = require('node:process');
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
|
@ -335,7 +336,6 @@ if (cluster.isPrimary) {
|
|||
}
|
||||
|
||||
// Start workers and listen for messages containing notifyRequest
|
||||
const numCPUs = require('node:os').availableParallelism();
|
||||
for (let i = 0; i < numCPUs; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue