mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
read MONGO_URL from environment in commands.js, not run*.js
This commit is contained in:
@@ -155,6 +155,8 @@ main.registerCommand({
|
||||
buildOptions: {
|
||||
minify: options.minify
|
||||
},
|
||||
mongoUrl: process.env.MONGO_URL,
|
||||
oplogUrl: process.env.MONGO_OPLOG_URL,
|
||||
once: options.once
|
||||
});
|
||||
});
|
||||
@@ -607,6 +609,10 @@ main.registerCommand({
|
||||
var findMongoPort =
|
||||
require(path.join(__dirname, 'run-mongo.js')).findMongoPort;
|
||||
var mongoPort = mongoRunner.findMongoPort(options.appDir);
|
||||
|
||||
// XXX detect the case where Meteor is running, but MONGO_URL was
|
||||
// specified?
|
||||
|
||||
if (! mongoPort) {
|
||||
process.stdout.write(
|
||||
"mongo: Meteor isn't running.\n" +
|
||||
@@ -660,6 +666,9 @@ main.registerCommand({
|
||||
return 1;
|
||||
}
|
||||
|
||||
// XXX detect the case where Meteor is running the app, but
|
||||
// MONGO_URL was set, so we don't see a Mongo process
|
||||
|
||||
var findMongoPort =
|
||||
require(path.join(__dirname, 'run-mongo.js')).findMongoPort;
|
||||
var isRunning = !! mongoRunner.findMongoPort(options.appDir);
|
||||
@@ -972,6 +981,8 @@ main.registerCommand({
|
||||
settingsFile: options.settings,
|
||||
banner: "Tests",
|
||||
buildOptions: buildOptions,
|
||||
mongoUrl: process.env.MONGO_URL,
|
||||
oplogUrl: process.env.MONGO_OPLOG_URL,
|
||||
once: options.once
|
||||
});
|
||||
}
|
||||
|
||||
@@ -249,7 +249,8 @@ _.extend(AppProcess.prototype, {
|
||||
// connections.
|
||||
//
|
||||
// - Other options: appDirForVersionCheck (defaults to appDir), port,
|
||||
// buildOptions, rootUrl, settingsFile, program, proxy, runLog
|
||||
// mongoUrl, oplogUrl, buildOptions, rootUrl, settingsFile, program,
|
||||
// proxy, runLog
|
||||
//
|
||||
// To use, construct an instance of AppRunner, and then call start()
|
||||
// to start it running. Call stop() at any time to shut it down and
|
||||
@@ -291,6 +292,8 @@ var AppRunner = function (appDir, options) {
|
||||
self.appDir = appDir;
|
||||
self.appDirForVersionCheck = options.appDirForVersionCheck || self.appDir;
|
||||
self.port = options.port;
|
||||
self.mongoUrl = options.mongoUrl;
|
||||
self.oplogUrl = options.oplogUrl;
|
||||
self.buildOptions = options.buildOptions;
|
||||
self.rootUrl = options.rootUrl;
|
||||
self.settingsFile = options.settingsFile;
|
||||
@@ -401,7 +404,7 @@ _.extend(AppRunner.prototype, {
|
||||
// Run the program
|
||||
var appProcess = new AppProcess({
|
||||
bundlePath: bundlePath,
|
||||
port: self.appPort,
|
||||
port: self.port,
|
||||
rootUrl: self.rootUrl,
|
||||
mongoUrl: self.mongoUrl,
|
||||
oplogUrl: self.oplogUrl,
|
||||
|
||||
@@ -125,17 +125,6 @@ var launchMongo = function (options) {
|
||||
var onListen = options.onListen || function () {};
|
||||
var onExit = options.onExit || function () {};
|
||||
|
||||
// If we are passed an external mongo, assume it is launched and never
|
||||
// exits. Matches code in runner.js:exports.run.
|
||||
if (process.env.MONGO_URL) {
|
||||
onListen();
|
||||
return {
|
||||
// Since it is externally managed, asking it to actually stop
|
||||
// would be impolite, so do nothing
|
||||
stop: function (callback) { callback(); }
|
||||
};
|
||||
}
|
||||
|
||||
var mongod_path = path.join(
|
||||
files.getDevBundle(), 'mongodb', 'bin', 'mongod');
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ var Updater = require('./updater.js').Updater;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// XXX XXX NEXT (if you want to do more):
|
||||
//
|
||||
// - MERGE ANDREW'S CHANGES ASAP
|
||||
// - make bundler.bundle() not take a release (get it from the app!)
|
||||
// - but don't do this until you merge andrew's stuff
|
||||
// - move mongo shell function from deploy.js into mongo-runner.js
|
||||
// - add warnings to buildmessage, per slava
|
||||
// - make files.getSettings return errors instead of throwing (or eliminate)
|
||||
@@ -39,23 +37,6 @@ var Runner = function (appDir, options) {
|
||||
self.appPort = self.listenPort + 1;
|
||||
self.mongoPort = self.listenPort + 2;
|
||||
|
||||
// XXX XXX set these in cooperation with MongoRunner
|
||||
|
||||
// Allow override and use of external mongo. Matches code in launch_mongo.
|
||||
// XXX make this value be an option, set by command.js from the environment
|
||||
self.mongoUrl = process.env.MONGO_URL ||
|
||||
("mongodb://127.0.0.1:" + mongoPort + "/meteor");
|
||||
|
||||
// Allow people to specify an MONGO_OPLOG_URL override. If someone specifies a
|
||||
// MONGO_URL but not an MONGO_OPLOG_URL, disable the oplog. If neither is
|
||||
// specified, use the default internal mongo oplog.
|
||||
self.oplogUrl = undefined;
|
||||
if (! options.disableOplog) {
|
||||
self.oplogUrl = process.env.MONGO_OPLOG_URL ||
|
||||
(process.env.MONGO_URL ? undefined
|
||||
: "mongodb://127.0.0.1:" + self.mongoPort + "/local");
|
||||
}
|
||||
|
||||
// XXX XXX have this be passed in, not slurped from the environment
|
||||
self.rootUrl =
|
||||
var rootUrl = process.env.ROOT_URL ||
|
||||
@@ -74,18 +55,31 @@ var Runner = function (appDir, options) {
|
||||
onFailure: options.onFailure
|
||||
});
|
||||
|
||||
self.mongoRunner = new MongoRunner({
|
||||
appDir: self.appDir,
|
||||
port: self.mongoPort,
|
||||
runLog: self.runLog,
|
||||
onFailure: options.onFailure
|
||||
});
|
||||
self.mongoRunner = null;
|
||||
var mongoUrl, oplogUrl;
|
||||
if (_.has(options, 'mongoUrl')) {
|
||||
mongoUrl = options.mongoUrl;
|
||||
oplogUrl = options.disableOplog ? null : options.oplogUrl;
|
||||
} else {
|
||||
self.mongoRunner = new MongoRunner({
|
||||
appDir: self.appDir,
|
||||
port: self.mongoPort,
|
||||
runLog: self.runLog,
|
||||
onFailure: options.onFailure
|
||||
});
|
||||
|
||||
mongoUrl = "mongodb://127.0.0.1:" + self.mongoPort + "/meteor";
|
||||
oplogUrl = (options.disableOplog ? null :
|
||||
"mongodb://127.0.0.1:" + self.mongoPort + "/local");
|
||||
}
|
||||
|
||||
self.updater = new Updater;
|
||||
|
||||
self.appRunner = new AppRunner(appDir, {
|
||||
appDirForVersionCheck: options.appDirForVersionCheck,
|
||||
port: self.appPort,
|
||||
mongoUrl: mongoUrl,
|
||||
oplogUrl: oplogUrl,
|
||||
buildOptions: options.buildOptions,
|
||||
rootUrl: self.rootUrl,
|
||||
settingsFile: options.settingsFile,
|
||||
@@ -109,7 +103,7 @@ _.extend(Runner.prototype, function () {
|
||||
process.stdout.write("[[[[[ " + self.banner + " ]]]]]\n\n");
|
||||
|
||||
self.updater.start();
|
||||
self.mongoRunner.start();
|
||||
self.mongoRunner && self.mongoRunner.start();
|
||||
self.appRunner.start();
|
||||
},
|
||||
|
||||
@@ -117,7 +111,7 @@ _.extend(Runner.prototype, function () {
|
||||
var self = this;
|
||||
self.proxy.stop();
|
||||
self.updater.stop();
|
||||
self.mongoRunner.stop();
|
||||
self.mongoRunner && self.mongoRunner.stop();
|
||||
self.appRunner.stop();
|
||||
self.runLog.finish();
|
||||
}
|
||||
@@ -155,6 +149,12 @@ _.extend(Runner.prototype, function () {
|
||||
// startup with an arbitrary string (eg, 'Tests')
|
||||
// - rawLogs: don't colorize/beautify log messages that are printed
|
||||
// - disableOplog: don't use oplog tailing
|
||||
// - mongoUrl: don't start a mongo process; instead use the mongo at
|
||||
// this mongo URL
|
||||
// - oplogUrl: URL of the mongo oplog to use. if mongoUrl isn't
|
||||
// set (we're starting a mongo) a default will be provided, but can
|
||||
// be overridden. if mongoUrl is set, you must set this or you don't
|
||||
// get oplog tailing.
|
||||
// - appDirForVersionCheck: when checking whether we're running the
|
||||
// right release of Meteor, check against this app rather than
|
||||
// appDir. Useful when you have autogenerated a test harness app
|
||||
|
||||
Reference in New Issue
Block a user