Created
January 17, 2018 15:15
-
-
Save fizerkhan/06c8c96c95e799d34047060562f6c758 to your computer and use it in GitHub Desktop.
Node Cluster with Atatus APM
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
var cluster = require('cluster'); | |
if (cluster.isMaster) { | |
// Count the machine's CPUs | |
var cpuCount = require('os').cpus().length; | |
// Create a worker for each CPU | |
for (var i = 0; i < cpuCount; i += 1) { | |
cluster.fork(); | |
} | |
// Listen for dying workers | |
cluster.on('exit', function () { | |
cluster.fork(); | |
}); | |
} else { | |
require('./server'); | |
} |
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
// This should be first line of your server.js | |
var atatus = require("atatus-node"); | |
atatus.start({ apiKey: "YOUR_API_KEY" }); | |
// Your Backend CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment