From 85292815058ebe44abfd5d6aadd84579572025da Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Mon, 5 Mar 2012 17:19:54 -0800 Subject: [PATCH] [refactor] Remove logging code from monitor. --- lib/forever/monitor.js | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/forever/monitor.js b/lib/forever/monitor.js index 3fba3832..0519f6e8 100644 --- a/lib/forever/monitor.js +++ b/lib/forever/monitor.js @@ -31,7 +31,7 @@ var Monitor = exports.Monitor = function (script, options) { // can be attached through `monitor.use(plugin, options)`. // function bootstrap(monitor) { - + forever.plugins.logger.attach.call(monitor, options); if (options.watch) { forever.plugins.watch.attach.call(monitor, options); } @@ -53,13 +53,12 @@ var Monitor = exports.Monitor = function (script, options) { this.checkFile = options.checkFile !== false; this.times = 0; this.warn = console.error; - // - // Setup log files and logger for this instance. - // - this.logFile = options.logFile || path.join(forever.config.get('root'), this.uid + '.log'); - this.outFile = options.outFile; - this.errFile = options.errFile; - this.append = options.append; + + this.logFile = options.logFile || path.join(forever.config.get('root'), this.uid + '.log'); + this.outFile = options.outFile; + this.errFile = options.errFile; + this.append = options.append; + // // Setup restart timing. These options control how quickly forever restarts // a child process as well as when to kill a "spinning" process @@ -143,25 +142,9 @@ Monitor.prototype.start = function (restart) { return this; } - if (!this.silent) { - child.stdout.pipe(process.stdout); - child.stderr.pipe(process.stderr); - if (this.outFile) { - child.stdout.pipe(fs.createWriteStream(this.outFile, { - flags: this.append ? 'a+' : 'w+' - })); - } - if (this.errFile) { - child.stderr.pipe(fs.createWriteStream(this.errFile, { - flags: this.append ? 'a+' : 'w+' - })); - } - } - this.ctime = Date.now(); this.child = child; this.running = true; - process.nextTick(function () { self.emit(restart ? 'restart' : 'start', self, self.data); }); @@ -356,7 +339,7 @@ Monitor.prototype.kill = function (forceStop) { // if (this.killTTL) { var timer = setTimeout(function () { - toKill.forEach(function(pid) { + toKill.forEach(function (pid) { try { process.kill(pid, 'SIGKILL'); } @@ -375,7 +358,7 @@ Monitor.prototype.kill = function (forceStop) { } } - forever.kill(this.child.pid, this.killTree, function() { + forever.kill(this.child.pid, this.killTree, function () { self.emit('stop', self.childData); }); }