mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Wrap some CLI functions in a Fiber
This commit is contained in:
21
app/lib/fiber-helpers.js
Normal file
21
app/lib/fiber-helpers.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// node (v8) defaults to only recording 10 lines of stack trace.
|
||||
// this becomes especially bad when using fibers, since you get deeper
|
||||
// stack traces that would have been split up between different callbacks
|
||||
//
|
||||
// this only affects the `meteor` executable, not server code on
|
||||
// meteor apps.
|
||||
Error.stackTraceLimit = Infinity; // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
||||
|
||||
var Fiber = require("fibers");
|
||||
|
||||
// runs a function within a fiber. we wrap the entry point into meteor.js into a fiber
|
||||
// but if you use callbacks that call synchronous code you need to wrap those as well.
|
||||
//
|
||||
// NOTE: It's probably better to not use callbacks. Instead you can
|
||||
// use Futures to generate synchronous equivalents.
|
||||
exports.inFiber = function(func) {
|
||||
return function() {
|
||||
new Fiber(func).run();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ var files = require(path.join(__dirname, '..', 'lib', 'files.js'));
|
||||
var _ = require('underscore');
|
||||
var keypress = require('keypress');
|
||||
var child_process = require('child_process');
|
||||
var inFiber = require(path.join(__dirname, '..', 'lib', 'fiber-helpers.js')).inFiber;
|
||||
|
||||
//
|
||||
// configuration
|
||||
@@ -352,6 +353,8 @@ var read_password = function (callback) {
|
||||
var with_password = function (site, callback) {
|
||||
var check_url = "https://" + DEPLOY_HOSTNAME + "/has_password/" + site;
|
||||
|
||||
callback = inFiber(callback);
|
||||
|
||||
request(check_url, function (error, response, body) {
|
||||
if (error || response.statusCode !== 200) {
|
||||
callback();
|
||||
|
||||
@@ -11,6 +11,7 @@ var updater = require(path.join(__dirname, '..', 'lib', 'updater.js'));
|
||||
var bundler = require(path.join(__dirname, '..', 'lib', 'bundler.js'));
|
||||
var mongo_runner = require(path.join(__dirname, '..', 'lib', 'mongo_runner.js'));
|
||||
var mongoExitCodes = require(path.join(__dirname, '..', 'lib', 'mongo_exit_codes.js'));
|
||||
var inFiber = require(path.join(__dirname, '..', 'lib', 'fiber-helpers.js')).inFiber;
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
@@ -601,7 +602,7 @@ exports.run = function (app_dir, bundle_opts, port, once, settingsFile) {
|
||||
}
|
||||
};
|
||||
|
||||
var restart_server = function () {
|
||||
var restart_server = inFiber(function () {
|
||||
Status.running = false;
|
||||
Status.listening = false;
|
||||
if (server_handle)
|
||||
@@ -700,7 +701,7 @@ exports.run = function (app_dir, bundle_opts, port, once, settingsFile) {
|
||||
}});
|
||||
}
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
var mongo_err_count = 0;
|
||||
|
||||
Reference in New Issue
Block a user