Skip to content

Commit

Permalink
[minor dist api] Small updates for storing a forever global config fi…
Browse files Browse the repository at this point in the history
…le. Update package.json using require-analyzer
  • Loading branch information
indexzero committed Apr 25, 2011
1 parent 6741c3a commit dffd0d1
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 44 deletions.
68 changes: 34 additions & 34 deletions bin/forever
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
20 changes: 20 additions & 0 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
};

Expand Down
38 changes: 28 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,43 @@
"version": "0.4.2",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
"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"
}
}

0 comments on commit dffd0d1

Please sign in to comment.