From b7315281be4389b1e6788b1fc2de630d028383b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfredo=20Gonz=C3=A1lez?= <12631491+mfdebian@users.noreply.github.com> Date: Tue, 30 Jul 2024 02:13:52 -0400 Subject: [PATCH] doc: move numCPUs require to top of file in cluster CJS example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/53932 Reviewed-By: Ulises Gascón Reviewed-By: James M Snell --- doc/api/cluster.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index aa2e9b4057e5fc..c5946ba8efb6c5 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -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(); }