I am using this code to handle cluster crashes in my node application
cluster.on('exit', function (worker, code, signal) {
console.log("error in cluster",worker);
console.log("cluster code",code);
console.log("cluster signal",signal);
const newFork = cluster.fork();
});
I am trying to get the reason for the worker going down but the data inside worker, code and signal parameters did not have any details about the error from what I could see. Is there any way to find what the reason for the crash is?
Listen to error event to get the error inside your fork.
const worker = cluster.fork();
worker.on("error", function(data) {
constole.log("error in cluster", data);
})