Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Created January 17, 2018 15:15
Show Gist options
  • Save fizerkhan/06c8c96c95e799d34047060562f6c758 to your computer and use it in GitHub Desktop.
Save fizerkhan/06c8c96c95e799d34047060562f6c758 to your computer and use it in GitHub Desktop.
Node Cluster with Atatus APM
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 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