Skip to content

Commit

Permalink
[fix minor] Keep processes silent on forever restart if requested. …
Browse files Browse the repository at this point in the history
…A couple of minor log formatting updates
  • Loading branch information
indexzero committed Jun 22, 2011
1 parent f11610e commit bc5995f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ forever.stat = function (logFile, script, callback) {

fs.stat(script, function (err, stats) {
if (err) {
return callback(new Error('Script ' + script + ' does not exist.'));
return callback(new Error('script ' + script + ' does not exist.'));
}

return logAppend ? callback(null) : fs.stat(logFile, function (err, stats) {
return !err
? callback(new Error('Log file ' + logFile + ' exists.'))
? callback(new Error('log file ' + logFile + ' exists.'))
: callback(null);
});
});
Expand Down Expand Up @@ -272,6 +272,10 @@ forever.restart = function (target, format) {
'--append'
];

if (proc.silent) {
restartCommand.push('--silent');
}

if (proc.outFile) {
restartCommand.push('-o', path.join(proc.sourceDir, proc.outFile));
}
Expand Down
8 changes: 7 additions & 1 deletion lib/forever/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ cli.restart = function (file) {
forever.log.info('No forever processes running');
}
});

runner.on('error', function (err) {
forever.log.error('Error restarting process: ' + file.grey);
forever.log.error(err.message);
});
};

//
Expand Down Expand Up @@ -239,7 +244,8 @@ function tryStart (file, options, callback) {

forever.stat(fullLog, fullScript, options.appendLog, function (err) {
if (err) {
forever.log.error('Cannot start forever: ' + err.message);
forever.log.error('Cannot start forever');
forever.log.error(err.message);
process.exit(-1);
}

Expand Down
7 changes: 4 additions & 3 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,15 @@ Monitor.prototype.save = function () {
}

var childData = {
uid: this.uid,
ctime: this.ctime,
command: this.command,
pid: this.child.pid,
file: this.options[0],
foreverPid: process.pid,
logFile: this.logFile,
options: this.options.slice(1),
file: this.options[0]
pid: this.child.pid,
silent: this.silent,
uid: this.uid
};

this.childData = childData;
Expand Down

0 comments on commit bc5995f

Please sign in to comment.