Skip to content

Commit

Permalink
Remove --debug option, replace with general NODE_OPTIONS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Naomi Seyfer committed Dec 18, 2012
1 parent 8ad174e commit e053201
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
12 changes: 2 additions & 10 deletions app/meteor/meteor.js
Expand Up @@ -117,10 +117,6 @@ Commands.push({
.describe('port', 'Port to listen on. NOTE: Also uses port N+1 and N+2.')
.boolean('production')
.describe('production', 'Run in production mode. Minify and bundle CSS and JS files.')
.boolean('debug')
.describe('debug', 'Pass --debug to node.js to enable node-inspector debugging.')
.boolean('debug-brk')
.describe('debug-brk', 'Pass --debug-brk to node.js to enable debugging and break on the first line.')
.describe('settings', 'Set optional data for Meteor.settings on the server')
.boolean('once')
.usage(
Expand Down Expand Up @@ -151,10 +147,7 @@ Commands.push({
var app_dir = path.resolve(require_project("run", true)); // app or package

var bundle_opts = { no_minify: !new_argv.production, symlink_dev_bundle: true };
var debugStatus = "OFF";
if (new_argv['debug']) debugStatus = "DEBUG";
if (new_argv['debug-brk']) debugStatus = "BREAK";
runner.run(app_dir, bundle_opts, new_argv.port, new_argv.once, settings, debugStatus);
runner.run(app_dir, bundle_opts, new_argv.port, new_argv.once, settings);
}
});

Expand Down Expand Up @@ -573,7 +566,7 @@ Commands.push({
"the password. You can change the password with a second 'deploy' command."
);

new_argv = opt.argv;
var new_argv = opt.argv;

if (argv.help || new_argv._.length != 2) {
process.stdout.write(opt.help());
Expand Down Expand Up @@ -682,4 +675,3 @@ var main = function() {
};

main();

41 changes: 21 additions & 20 deletions app/meteor/run.js
Expand Up @@ -74,8 +74,17 @@ var Status = {
}
};

// Parse out s as if it were a bash command line.
var bashParse = function (s) {
if (s.search("\"") !== -1 || s.search("'") !== -1) {
throw new Error("Meteor cannot currently handle quoted NODE_OPTIONS");
}
return _.without(s.split(/\s+/), '');
};


var getNodeOptionsFromEnvironment = function () {
return bashParse(process.env.NODE_OPTIONS || "");
};

// List of queued requests. Each item in the list is a function to run
// when the inner app is ready to receive connections.
Expand Down Expand Up @@ -203,18 +212,17 @@ var log_to_clients = function (msg) {
// mongoURL
// onExit
// [onListen]
// [debugStatus]
//
// [nodeOptions]
// [runOnce]: boolean; default false; if true doesn't ever try to restart, and
// forwards server exit code.
// [settings]

var start_server = function (options) {
// environment
options = _.extend({runOnce: false,
debugStatus: "OFF"
},
options);
options = _.extend({
runOnce: false,
nodeOptions: []
}, options);
if (options.runOnce) {
Status.shouldRestart = false;
}
Expand All @@ -226,22 +234,15 @@ var start_server = function (options) {
env.PORT = options.innerPort;
env.MONGO_URL = options.mongoURL;
env.ROOT_URL = env.ROOT_URL || ('http://localhost:' + options.outerPort);

var dbg = options.debugStatus;
var nodeOptions = [];
if (dbg === "DEBUG")
nodeOptions.push('--debug');
if (dbg === "BREAK") {
console.log('Debug will break on the first line');
nodeOptions.push('--debug-brk');
}

if (options.settings)
env.METEOR_SETTINGS = options.settings;

var nodeOptions = _.clone(options.nodeOptions);
nodeOptions.push(path.join(options.bundlePath, 'main.js'));
nodeOptions.push('--keepalive');

var proc = spawn(process.execPath,
nodeOptions.concat([path.join(options.bundlePath, 'main.js'), '--keepalive']),
nodeOptions,
{env: env});

// XXX deal with test server logging differently?!
Expand Down Expand Up @@ -511,7 +512,7 @@ var start_update_checks = function () {
// This function never returns and will call process.exit() if it
// can't continue. If you change this, remember to call
// watcher.destroy() as appropriate.
exports.run = function (app_dir, bundle_opts, port, once, settings, dbg) {
exports.run = function (app_dir, bundle_opts, port, once, settings) {
var outer_port = port || 3000;
var inner_port = outer_port + 1;
var mongo_port = outer_port + 2;
Expand Down Expand Up @@ -631,7 +632,7 @@ exports.run = function (app_dir, bundle_opts, port, once, settings, dbg) {
_.each(request_queue, function (f) { f(); });
request_queue = [];
},
debugStatus: dbg,
nodeOptions: getNodeOptionsFromEnvironment(),
runOnce: once,
settings: settings
});
Expand Down
3 changes: 3 additions & 0 deletions docs/client/commandline.html
Expand Up @@ -29,6 +29,9 @@ <h3 id="meteorrun">meteor run</h3>
This is the default command. Simply running `meteor` is the
same as `meteor run`.

To pass additional options to Node.js use the `NODE_OPTIONS` environment variable.
For example: `NODE_OPTIONS='--debug'` or `NODE_OPTIONS='--debug-brk'`

Run `meteor help run` to see the full list of options.


Expand Down

0 comments on commit e053201

Please sign in to comment.