Created
April 22, 2016 21:49
-
-
Save evantahler/3138ebd3fedb07f29e69b356afc6ec70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var reloadAWorker = function(next){ | |
var count = 0; | |
for (var i in cluster.workers){ count++; } | |
if(workersExpected > count){ | |
startAWorker(); | |
} | |
if(workerRestartArray.length > 0){ | |
var worker = workerRestartArray.pop(); | |
worker.send("stop"); | |
} | |
} | |
cluster.on('exit', function(worker, code, signal) { | |
log("worker " + worker.process.pid + " (#"+worker.id+") has exited"); | |
setTimeout(reloadAWorker, 1000) // to prevent CPU-splsions if crashing too fast | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment