Complete the code to import the cluster module.
const cluster = require('[1]');
The cluster module is imported using require('cluster') to enable forking workers.
Complete the code to import the OS module.
const os = require('[1]');
The os module is imported using require('os') to access CPU core information.
Fix the error in the code to get the number of CPU cores.
const numCPUs = os.[1]();The correct method to get CPU cores is os.cpus(), which returns an array of CPU info.
Fill both blanks to fork a worker for each CPU core.
if (cluster.[1]) { for (let i = 0; i < numCPUs.[2]; i++) { cluster.fork(); } }
Use cluster.isPrimary to check if the process is the primary one, and numCPUs.length to get the number of CPU cores.
Fill all three blanks to log when a worker exits and fork a new one.
cluster.on('[1]', (worker, code, signal) => { console.log(`Worker ${worker.[2] died`); cluster.[3](); });
The event to listen for is 'exit'. The worker's process ID is accessed with worker.pid. To create a new worker, call cluster.fork().