Skip to content

Commit

Permalink
[dist] Various small esoteric changes. Fixes #179
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Dec 2, 2011
1 parent 061d14f commit dcbfc70
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
4 changes: 1 addition & 3 deletions bin/forever
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node

var forever = require('./../lib/forever');

forever.cli.startCLI();
require('./../lib/forever').cli.start();

2 changes: 1 addition & 1 deletion examples/list-multiple.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var path = require('path'),
async = require('async'),
async = require('utile').async,
forever = require('../lib/forever');

function startServer (port, next) {
Expand Down
24 changes: 16 additions & 8 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ var fs = require('fs'),
events = require('events'),
exec = require('child_process').exec,
net = require('net'),
async = require('async'),
colors = require('colors'),
cliff = require('cliff'),
daemon = require('daemon'),
nconf = require('nconf'),
mkdirp = require('mkdirp').mkdirp,
portfinder = require('portfinder'),
timespan = require('timespan'),
spawn = require('child_process').spawn,
psTree = require('ps-tree'),
utile = require('utile'),
mkdirp = utile.mkdirp,
async = utile.async,
winston = require('winston');

var forever = exports;
Expand All @@ -43,7 +42,7 @@ forever.log.cli();
//
forever.initialized = false;
forever.root = path.join(process.env.HOME || '/root', '.forever');
forever.config = new nconf.stores.File({ file: path.join(forever.root, 'config.json') });
forever.config = new nconf.File({ file: path.join(forever.root, 'config.json') });
forever.Forever = forever.Monitor = require('./forever/monitor').Monitor;
forever.cli = require('./forever/cli');

Expand Down Expand Up @@ -118,7 +117,7 @@ function getAllProcesses(callback) {
});

socket.on('data', function (msg) {
data += msg.toString();
data += msg;
});

socket.on('close', function () {
Expand All @@ -127,9 +126,18 @@ function getAllProcesses(callback) {
monitors = JSON.parse(data);
}
catch (ex) {
return next();
//
// Ignore errors
//
}

//
// Be a little lazier about loading results
//
if (monitors && monitors.monitors) {
results = results.concat(monitors.monitors);
}
results.push.apply(results, monitors.monitors);

next();
});

Expand Down Expand Up @@ -185,7 +193,7 @@ forever.load = function (options) {
return;
}

forever.config = new nconf.stores.File({ file: path.join(options.root, 'config.json') });
forever.config = new nconf.File({ file: path.join(options.root, 'config.json') });

//
// Try to load the forever `config.json` from
Expand Down
17 changes: 7 additions & 10 deletions lib/forever/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ var argvOptions = {
'plain': {boolean: true}
};

app.use(flatiron.plugins.config);
app.config.argv(argvOptions).env();

var reserved = ['root', 'pidPath'];
Expand Down Expand Up @@ -171,7 +170,7 @@ function getOptions(file) {
// we've removed some before.
//
app.config.stores.argv.store = {};
app.config.stores.argv.loadSync();
app.config.use('argv');

[
'pidFile', 'logFile', 'errFile', 'watch', 'minUptime', 'appendLog',
Expand Down Expand Up @@ -462,13 +461,11 @@ app.cmd(/(.*)/, cli.start = function (file) {
});
});

cli.startCLI = function () {
app.init(function () {
if (app.config.get('help')) {
return util.puts(help.join('\n'));
}

app.start();
});
cli.start = function () {
if (app.config.get('help')) {
return util.puts(help.join('\n'));
}

app.init(app.start);
};

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
"tools"
],
"dependencies": {
"async": "0.1.x",
"colors": "0.x.x",
"cliff": "0.x.x",
"clip": "0.x.x",
"dnode": "0.8.x",
"daemon": "0.3.x >=0.3.2",
"flatiron": "0.1.x",
"minimatch": "0.0.x",
"mkdirp": "0.x.x",
"nconf": "0.4.x",
"nconf": "0.5.x",
"optimist": "0.2.x",
"pkginfo": "0.x.x",
"portfinder": "0.x.x",
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ helpers.spawn = function (args, options) {
// doesn't wait for slave to start up after it's forked, it just quits)
//
setTimeout(function () {
self.callback(exitCode, stdout, stderr);
self.callback(null, exitCode, stdout, stderr);
}, 200);
});
};
Expand Down

0 comments on commit dcbfc70

Please sign in to comment.