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
Alfredo González 2024-07-30 02:13:52 -04:00 committed by GitHub
parent 890760b8e5
commit 027710e408
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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();
}