Skip to content

Instantly share code, notes, and snippets.

@mirajehossain
Last active September 11, 2021 19:45
Show Gist options
  • Save mirajehossain/bda4e0825b0b9803e30bbd7cac53953b to your computer and use it in GitHub Desktop.
Save mirajehossain/bda4e0825b0b9803e30bbd7cac53953b to your computer and use it in GitHub Desktop.
increase availability of node application
// to increase the availability of the application
// we create new worker using fork() method if the worker is crushed.
// so that we can increase our applications availability.
if (code !== 0 && !worker.exitedAfterDisconnect) {
console.log(`Worker ${worker.id} crashed. \nStarting a new worker...`);
cluster.fork();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment