Skip to content

Commit

Permalink
[refactor] Remove logging code from monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu committed Mar 6, 2012
1 parent 70ae4f4 commit 8529281
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);
});
}
Expand Down

0 comments on commit 8529281

Please sign in to comment.