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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mfdebian authored and marco-ippolito committed Aug 19, 2024
1 parent bd996bf commit 30310bf
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 30310bf

Please sign in to comment.