cluster-file-writer
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -6,17 +6,6 @@ var fs = require('fs'); | ||
var self = this; | ||
this._log = fs.createWriteStream(path); | ||
this._pausedWorkers = []; | ||
this._log.on('drain', function () { | ||
this.setupFile(path); | ||
try { | ||
while(self._pausedWorkers.length > 0) { | ||
var worker = self._pausedWorkers.pop(); | ||
worker.send('cluster-file-writer-resume'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}); | ||
this.messagesWritten = 0; | ||
@@ -52,2 +41,24 @@ this.workersCount = 0; | ||
Master.prototype.setupFile = function(path) { | ||
var self = this; | ||
if (this._log) { | ||
this._log.end(); | ||
} | ||
this.currentPath = path; | ||
this._log = fs.createWriteStream(path); | ||
this._log.on('drain', function () { | ||
try { | ||
while(self._pausedWorkers.length > 0) { | ||
var worker = self._pausedWorkers.pop(); | ||
worker.send('cluster-file-writer-resume'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}); | ||
} | ||
Master.prototype._handleIncomingMessages = function (worker) { | ||
@@ -54,0 +65,0 @@ var self = this; |
{ | ||
"name": "cluster-file-writer", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "write to a single file from a cluster", | ||
@@ -5,0 +5,0 @@ "keywords": ["cluster", "logger", "filesystem", "file"], |
@@ -26,2 +26,8 @@ var assert = require('assert'); | ||
// setTimeout(function () { | ||
// console.log('switching files'); | ||
// writer.setupFile('test2.log'); | ||
// }, 10000); | ||
var ref = setInterval(function() { | ||
@@ -31,2 +37,3 @@ if (lastMW > 0) { | ||
} | ||
@@ -33,0 +40,0 @@ lastMW = writer.messagesWritten; |
Sorry, the diff of this file is not supported yet
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
241
10421
10