cluster-file-writer
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -12,3 +12,8 @@ var fs = require('fs'); | ||
var worker = self._pausedWorkers.pop(); | ||
worker.send('cluster-file-writer-resume'); | ||
try { | ||
worker.send('cluster-file-writer-resume'); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
@@ -25,2 +30,22 @@ }); | ||
}); | ||
cluster.on('disconnect', function(worker) { | ||
removeFromPausedWorkers(worker); | ||
}); | ||
cluster.on('exit', function(worker, code, signal) { | ||
removeFromPausedWorkers(worker); | ||
}); | ||
function removeFromPausedWorkers(worker) { | ||
for (var i = 0; i < self._pausedWorkers.length; i++) { | ||
var pausedWorker = self._pausedWorkers[i]; | ||
if (pausedWorker.id = worker.id) { | ||
self._pausedWorkers = self._pausedWorkers.splice(1, 1); | ||
console.log('worker found and removed from paused'); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
@@ -35,4 +60,8 @@ | ||
if (!resume) { | ||
worker.send('cluster-file-writer-pause'); | ||
if (!resume) { | ||
try { | ||
worker.send('cluster-file-writer-pause'); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
self._pausedWorkers.push(worker); | ||
@@ -77,4 +106,3 @@ } | ||
Worker.prototype._resume = function () { | ||
this._paused = false; | ||
//console.log('resuming', this.messageCount); | ||
this._paused = false; | ||
}; | ||
@@ -84,3 +112,2 @@ | ||
this._paused = true; | ||
//console.log('pausing', this.messageCount); | ||
}; | ||
@@ -87,0 +114,0 @@ |
{ | ||
"name": "cluster-file-writer", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "write to a single file from a cluster", | ||
@@ -5,0 +5,0 @@ "keywords": ["cluster", "logger", "filesystem", "file"], |
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
3967716
11
198
7