cluster-rolling-restart
Advanced tools
Comparing version 1.0.10 to 1.0.12
20
index.js
@@ -72,10 +72,14 @@ "use strict"; | ||
* Control execution of stop/start request | ||
* @returns {boolean} true to continue, otherwise stop | ||
* @param {function()} callback - a callback that starts your app | ||
* @param {number} waitms - Delay execution by `waitms` | ||
* milliseconds so your app has time to start | ||
*/ | ||
function continueReload(callback, waitms) { | ||
if ( | ||
reloading || | ||
(workerList.length < numCores && callback.name.includes("start")) | ||
) { | ||
setTimeout(() => callback(), waitms); | ||
const failedWorker = | ||
!reloading && | ||
workerList.length < numCores && | ||
callback.name.includes("start"); | ||
if (reloading || failedWorker) { | ||
setTimeout(callback, failedWorker ? 60000 : waitms); | ||
} | ||
@@ -107,3 +111,3 @@ } | ||
console.log("worker down", worker.process.pid); | ||
continueReload(startWorker, waitms); | ||
continueReload(startWorker, 0); | ||
}); | ||
@@ -114,3 +118,3 @@ | ||
console.log("worker up", worker.process.pid); | ||
continueReload(stopWorker, 0); | ||
continueReload(stopWorker, waitms); | ||
}); | ||
@@ -117,0 +121,0 @@ |
{ | ||
"name": "cluster-rolling-restart", | ||
"version": "1.0.10", | ||
"version": "1.0.12", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Tyson Midboe", |
@@ -5,3 +5,3 @@ # cluster-rolling-restart | ||
## Install | ||
## Install [<img src="https://github.com/tysonrm/cluster-rolling-restart/blob/main/npm-tile.png">](https://www.npmjs.com/package/cluster-rolling-restart) | ||
@@ -20,4 +20,4 @@ ```shell | ||
app.get("/", (req, res) => res.send(`I'm pid ${process.pid}`)); | ||
app.get("/reload", (req, res) => process.send({ cmd: "reload" })); | ||
app.get("/reload-reset", (req, res) => process.send({ cmd: "reload-reset" })); | ||
@@ -24,0 +24,0 @@ cluster.startCluster(() => app.listen(8080)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9907
7
133