diff --git a/bin/forever b/bin/forever index 1a215765..c369ffce 100755 --- a/bin/forever +++ b/bin/forever @@ -16,40 +16,40 @@ require.paths.unshift(path.join(__dirname, '..', 'lib')); var forever = require('forever'); var help = [ - 'usage: forever [start | stop | restart | stopall | list | cleanlogs] [options] SCRIPT [script options]', - '', - 'options:', - ' start start SCRIPT as a daemon', - ' stop stop the daemon SCRIPT', - ' stopall stop all running forever scripts', - ' restart restart the daemon SCRIPT', - ' list list all running forever scripts', - ' cleanlogs [CAREFUL] Deletes all historical forever log files', - '', - ' -m MAX Only run the specified script MAX times', - ' -l LOGFILE Logs the forever output to LOGFILE', - ' -a, --append Append logs', - ' -o OUTFILE Logs stdout from child script to OUTFILE', - ' -e ERRFILE Logs stderr from child script to ERRFILE', - ' -d SOURCEDIR The source directory for which SCRIPT is relative to', - ' -p PATH Base path for all forever related filesĀ (pid files, etc.)', - ' -c COMMAND COMMAND to execute (defaults to node)', - ' --pidfile The pid file', - ' -v, --verbose Turns on the verbose messages from Forever', - ' -s, --silent Run the child script silencing stdout and stderr', - ' -h, --help You\'re staring at it', - '', - '[Long Running Process]', - ' The forever process will continue to run outputting log messages to the console.', - ' ex. forever -o out.log -e err.log my-script.js', - '', - '[Daemon]', - ' The forever process will run as a daemon which will make the target process start', - ' in the background. This is extremely useful for remote starting simple node.js scripts', - ' without using nohup. It is recommended to run start with -o -l, & -e.', - ' ex. forever start -l forever.log -o out.log -e err.log my-daemon.js', - ' forever stop my-daemon.js', - '' + 'usage: forever [start | stop | restart | stopall | list | cleanlogs] [options] SCRIPT [script options]', + '', + 'options:', + ' start start SCRIPT as a daemon', + ' stop stop the daemon SCRIPT', + ' stopall stop all running forever scripts', + ' restart restart the daemon SCRIPT', + ' list list all running forever scripts', + ' cleanlogs [CAREFUL] Deletes all historical forever log files', + '', + ' -m MAX Only run the specified script MAX times', + ' -l LOGFILE Logs the forever output to LOGFILE', + ' -a, --append Append logs', + ' -o OUTFILE Logs stdout from child script to OUTFILE', + ' -e ERRFILE Logs stderr from child script to ERRFILE', + ' -d SOURCEDIR The source directory for which SCRIPT is relative to', + ' -p PATH Base path for all forever related filesĀ (pid files, etc.)', + ' -c COMMAND COMMAND to execute (defaults to node)', + ' --pidfile The pid file', + ' -v, --verbose Turns on the verbose messages from Forever', + ' -s, --silent Run the child script silencing stdout and stderr', + ' -h, --help You\'re staring at it', + '', + '[Long Running Process]', + ' The forever process will continue to run outputting log messages to the console.', + ' ex. forever -o out.log -e err.log my-script.js', + '', + '[Daemon]', + ' The forever process will run as a daemon which will make the target process start', + ' in the background. This is extremely useful for remote starting simple node.js scripts', + ' without using nohup. It is recommended to run start with -o -l, & -e.', + ' ex. forever start -l forever.log -o out.log -e err.log my-daemon.js', + ' forever stop my-daemon.js', + '' ].join('\n'); var mappings = { diff --git a/lib/forever.js b/lib/forever.js index 0e032cda..f26ff290 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -52,6 +52,17 @@ forever.load = function (options) { return; } + forever.config = new nconf.stores.File({ file: path.join(options.root, 'config.json') }); + + // + // Try to load the forever `config.json` from + // the specified location. + // + try { + forever.config.loadSync(); + } + catch (ex) { } + forever.config.set('root', options.root); forever.config.set('pidPath', options.pidPath); @@ -68,6 +79,15 @@ forever.load = function (options) { tryCreate(forever.config.get('root')); tryCreate(forever.config.get('pidPath')); + + // + // Attempt to save the new `config.json` for forever + // + try { + forever.config.saveSync(); + } + catch (ex) { } + forever.initialized = true; }; diff --git a/package.json b/package.json index 6259399f..97827324 100644 --- a/package.json +++ b/package.json @@ -4,25 +4,43 @@ "version": "0.4.2", "author": "Charlie Robbins ", "contributors": [ - { "name": "Fedor Indutny", "email": "fedor.indutny@gmail.com" }, - { "name": "James Halliday", "email": "mail@substack.net" } + { + "name": "Fedor Indutny", + "email": "fedor.indutny@gmail.com" + }, + { + "name": "James Halliday", + "email": "mail@substack.net" + } ], "repository": { "type": "git", - "url": "http://github.com/indexzero/forever.git" + "url": "http://github.com/indexzero/forever.git" }, - "keywords": ["cli", "fault tolerant", "sysadmin", "tools"], + "keywords": [ + "cli", + "fault tolerant", + "sysadmin", + "tools" + ], "dependencies": { "async": ">= 0.1.8", - "colors": ">= 0.3.0", + "colors": ">= 0.5.0", "daemon": ">= 0.3.0", "optimist": ">= 0.0.6", "timespan": ">= 2.0.0", "vows": ">= 0.5.2", - "winston": ">= 0.2.1" + "winston": ">= 0.2.7", + "nconf": ">= 0.1.7" + }, + "bin": { + "forever": "./bin/forever" }, - "bin": { "forever": "./bin/forever" }, "main": "./lib/forever", - "scripts": { "test": "vows test/*-test.js --spec" }, - "engines": { "node": ">= 0.4.0" } -} + "scripts": { + "test": "vows test/*-test.js --spec" + }, + "engines": { + "node": ">= 0.4.0" + } +} \ No newline at end of file