From 9d353153edc57769636f856cafac1430a3c4c846 Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 11 Jul 2011 12:00:32 -0400 Subject: [PATCH] [fix minor] Update how forever._debug works. Use updated CLI options in `forever restart` --- bin/forever | 5 ++++- lib/forever.js | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/forever b/bin/forever index 82adc938..d795edc8 100755 --- a/bin/forever +++ b/bin/forever @@ -212,7 +212,10 @@ if ((config.root && config.root !== forever.root)) { // it to the default `forever._debug`. // process.on('uncaughtException', function (err) { - console.dir(err.stack.split('\n')); + forever._debug(); + forever.log.error('uncaughtException'); + forever.log.error(err.message); + forever.log.error(err.stack); }); // diff --git a/lib/forever.js b/lib/forever.js index e89f5a34..a0bd61c1 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -90,7 +90,6 @@ forever.load = function (options) { ]; } - forever.config.set('root', options.root); forever.config.set('pidPath', options.pidPath); forever.config.set('sockPath', options.sockPath); @@ -138,10 +137,15 @@ forever.load = function (options) { // Sets up debugging for this forever process // forever._debug = function () { - forever.config.set('debug', true); - forever.log.add(winston.transports.File, { - filename: path.join(forever.config.get('root'), 'forever.debug.log') - }); + var debug = forever.config.get('debug'); + + if (!debug) { + forever.config.set('debug', true); + forever.log.add(winston.transports.File, { + level: 'silly', + filename: path.join(forever.config.get('root'), 'forever.debug.log') + }); + } } // @@ -329,7 +333,7 @@ forever.restart = function (target, format) { var restartCommand = [ 'forever', 'start', - '-d', proc.sourceDir, + '--sourceDir', proc.sourceDir, '-l', proc.logFile, '--append' ]; @@ -347,6 +351,8 @@ forever.restart = function (target, format) { } restartCommand.push(proc.file, proc.options.join(' ')); + forever.log.silly('Restarting with options', { options: restartCommand.join(' ') }); + exec(restartCommand.join(' '), function (err, stdout, stderr) { next(); });