Socket
Socket
Sign inDemoInstall

cluster-service

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-service - npm Package Compare versions

Comparing version 0.5.15 to 0.6.0

2

lib/commands/shutdown.js

@@ -10,3 +10,3 @@ var

options.timeout = parseInt(options.timeout) || 60000;
if (typeof cmd !== "string" || (cmd !== "all" && !pid)) {
if (cmd !== "all" && !pid) {
cb("Invalid request. Try help shutdown");

@@ -13,0 +13,0 @@ return;

@@ -52,7 +52,7 @@ var

worker.process = msg.processDetails;
worker.processDetails = msg.processDetails;
cb(null, worker);
});
// todo! timeout needed? perhaps.
worker.send({ cservice: "processDetails" });
worker.process.send({ cservice: "processDetails" });
};

@@ -72,3 +72,3 @@ }

cwd: w.cservice.cwd,
process: w.process
process: w.processDetails
});

@@ -75,0 +75,0 @@ }

@@ -28,2 +28,4 @@ var

json: false, // output as JSON
restartOnMemUsage: undefined,
restartOnUpTime: undefined,
colors: {

@@ -30,0 +32,0 @@ cservice: "grey",

@@ -5,2 +5,3 @@ var

httpserver = require("./http-server"),
async = require("async"),
startRequests = [] // queued start requests

@@ -58,2 +59,5 @@ ;

// start monitor
monitorWorkers();
if (options.cli === true) {

@@ -123,1 +127,44 @@ // wire-up CLI

}
function monitorWorkers() {
if (cservice.options.restartOnMemUsage || cservice.options.restartOnUpTime) {
setTimeout(onMonitorWorkers, 20000).unref(); // do not hold server open
}
}
function onMonitorWorkers() {
cservice.trigger("workers", function(err, results) {
if (err || !results || !results.workers) {
// nothing we can do about it at this time
setTimeout(onMonitorWorkers, 60000).unref(); // do not hold server open
return;
}
var workers = results.workers;
var restarts = [];
var memUsage = cservice.options.restartOnMemUsage;
var upTime = cservice.options.restartOnUpTime;
for (var i = 0; i < workers.length; i++) {
var w = workers[i];
if (
(memUsage && w.process.memoryUsage.rss > memUsage)
||
(upTime && w.process.uptime > upTime)
) {
restarts.push(getWorkerToRestart(w));
}
}
if (restarts.length > 0) {
async.series(restarts, function(err, results) {
setTimeout(onMonitorWorkers, 20000).unref(); // do not hold server open
});
} else {
setTimeout(onMonitorWorkers, 30000).unref(); // do not hold server open
}
}, "simple");
}
function getWorkerToRestart(worker) {
return function(cb) {
cservice.trigger("restart", cb, worker.pid);
};
}

@@ -10,3 +10,7 @@ var

if (!evt) {
throw new Error("Event " + eventName + " not found");
if (typeof arguments[1] === "function") { // invoke callback if provided instead of throwing
arguments[1]("Event " + eventName + " not found");
} else {
throw new Error("Event " + eventName + " not found");
}
}

@@ -13,0 +17,0 @@

{
"name": "cluster-service",
"version": "0.5.15",
"version": "0.6.0",
"author": {

@@ -5,0 +5,0 @@ "name": "Aaron Silvas",

@@ -27,2 +27,6 @@ # cluster-service

Presentation:
http://x.co/bpnode
Stability:

@@ -141,2 +145,6 @@

not recommended otherwise.
* restartOnMemUsage (default: disabled) - If a worker process exceeds the specified memory threshold
(in bytes), the process will be restarted gracefully. Only one worker will be restarted at a time.
* restartOnUpTime (default: disabled) - If a worker process exceeds the specified uptime threshold
(in seconds), the process will be restarted gracefully. Only one worker will be restarted at a time.

@@ -143,0 +151,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc