From 8186994cad2c4608e73ad064f675a65525665fd7 Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Tue, 28 Feb 2012 13:28:51 -0800 Subject: [PATCH] [fix] Alter logging paths to reduce memory leakage and prevent stdio issues. --- lib/forever.js | 6 ++++++ lib/forever/monitor.js | 16 ++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/forever.js b/lib/forever.js index f44d7533..9fd36091 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -353,6 +353,12 @@ forever.stat = function (logFile, script, callback) { // Starts a script with forever // forever.start = function (script, options) { + if (!options.uid) { + options.uid = options.uid || utile.randomString(4).replace(/^\-/, '_'); + } + if (!options.logFile) { + options.logFile = forever.logFilePath(options.uid + '.log'); + } return new forever.Monitor(script, options).start(); }; diff --git a/lib/forever/monitor.js b/lib/forever/monitor.js index e5f70484..caff7bba 100644 --- a/lib/forever/monitor.js +++ b/lib/forever/monitor.js @@ -31,7 +31,6 @@ 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,6 +52,7 @@ var Monitor = exports.Monitor = function (script, options) { this.childExists = false; this.checkFile = options.checkFile !== false; this.times = 0; + this.daemon = options.daemon || false; // // Setup log files and logger for this instance. @@ -60,15 +60,6 @@ var Monitor = exports.Monitor = function (script, options) { this.logFile = options.logFile || path.join(forever.config.get('root'), this.uid + '.log'); this.outFile = options.outFile; this.errFile = options.errFile; - this.logger = options.logger || new (winston.Logger)({ - transports: [new winston.transports.Console({ silent: this.silent })] - }); - - // - // Extend from the winston logger. - // - this.logger.extend(this); - this.log = fs.createWriteStream(this.logFile, { flags: 'a+', encoding: 'utf8', mode: '0666' }); // // Setup restart timing. These options control how quickly forever restarts @@ -153,6 +144,11 @@ Monitor.prototype.start = function (restart) { return this; } + if (!this.silent) { + child.stdout.pipe(process.stdout); + child.stderr.pipe(process.stderr); + } + this.ctime = Date.now(); this.child = child; this.running = true;