Created
August 28, 2019 12:27
-
-
Save tsh-code/84cc0ccdd4261aaa5b041ef92e49699d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (cluster.isMaster) { | |
console.log(`Master ${process.pid} is running`) | |
for (let i = 0; i < numCPUs; i++) { | |
cluster.fork() | |
} | |
cluster.on('exit', (worker, code, signal) => { | |
console.log(`worker ${worker.process.pid} died`) | |
}) | |
} else { | |
const express = require('express') | |
const app = express() | |
// define our endpoints here | |
app.listen(port) | |
console.log(`Process ${process.pid} started`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment