Last active
September 11, 2021 19:45
-
-
Save mirajehossain/bda4e0825b0b9803e30bbd7cac53953b to your computer and use it in GitHub Desktop.
increase availability of node application
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
// 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