Skip to content

Commit

Permalink
[fix] Ensure forever script.js works
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jan 5, 2012
1 parent 285b659 commit b830218
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/forever/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ app.use(flatiron.plugins.cli, {
usage: help
});

var actions = [
'start',
'stop',
'restart',
'list',
'config',
'set',
'clear',
'logs',
'columns',
'cleanlogs'
];

var argvOptions = cli.argvOptions = {
'command': {alias: 'c'},
'errFile': {alias: 'e'},
Expand Down Expand Up @@ -453,22 +466,29 @@ app.cmd('help', cli.help = function () {
// Remark: this regex matches everything. It has to be added at the end to
// make executing other commands possible.
//
app.cmd(/(.*)/, cli.start = function () {
var file = require('optimist').argv._[0],
cli.run = function () {
var file = app.argv._[0],
options = getOptions(file);

tryStart(file, options, function () {
var monitor = forever.start(file, options);
monitor.on('start', function () {
forever.startServer(monitor);
});
});
});
};

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

app.init(app.start);
app.init(function () {
if (actions.indexOf(app.argv._[0]) === -1) {
return cli.run();
}

app.start();
});
};

0 comments on commit b830218

Please sign in to comment.