Skip to content

Commit

Permalink
doc: move numCPUs require to top of file in cluster CJS example
Browse files Browse the repository at this point in the history
PR-URL: #53932
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
mfdebian authored and targos committed Jul 30, 2024
1 parent da1c315 commit 9b20410
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down

0 comments on commit 9b20410

Please sign in to comment.