Note:
For PM2 Cluster mode, you dont need this setup. You can just follow normal installation steps.
All you have to do is, to install the atatus-node from npm, and then add require('atatus-node') statement in the first line of your server code(NOT in your cluster code).
Please refer our example:
copy
// index.js
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');
}
copy
// server.js
// This should be the first line of your server.js
var atatus = require("atatus-nodejs");
atatus.start({
licenseKey: "YOUR_LICENSE_KEY",
appName: "YOUR_APP_NAME"
});
// Your Backend CODE