mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
incorporating MONGO_URL into default app config
This commit is contained in:
@@ -5,10 +5,7 @@ Galaxy = {};
|
||||
|
||||
Galaxy.findGalaxy = _.once(function () {
|
||||
if (!('GALAXY' in process.env || 'ULTRAWORLD_DDP_ENDPOINT' in process.env)) {
|
||||
console.log(
|
||||
"To do Meteor Galaxy operations like binding to a Galaxy " +
|
||||
"proxy, the ULTRAWORLD_DDP_ENDPOINT environment variable must be set.");
|
||||
process.exit(1);
|
||||
return null;
|
||||
}
|
||||
|
||||
return DDP.connect(process.env.GALAXY || process.env.ULTRAWORLD_DDP_ENDPOINT);
|
||||
@@ -20,28 +17,41 @@ Galaxy.findGalaxy = _.once(function () {
|
||||
var ultra = Galaxy.findGalaxy();
|
||||
|
||||
var subFuture = new Future();
|
||||
ultra.subscribe("oneApp", process.env.GALAXY_APP, subFuture.resolver());
|
||||
if (ultra)
|
||||
ultra.subscribe("oneApp", process.env.GALAXY_APP, subFuture.resolver());
|
||||
|
||||
var OneAppApps;
|
||||
var Services;
|
||||
var collectionFuture = new Future();
|
||||
|
||||
Meteor.startup(function () {
|
||||
OneAppApps = new Meteor.Collection("apps", {
|
||||
connection: ultra
|
||||
});
|
||||
Services = new Meteor.Collection('services', {
|
||||
manager: ultra
|
||||
});
|
||||
collectionFuture.return();
|
||||
if (ultra) {
|
||||
OneAppApps = new Meteor.Collection("apps", {
|
||||
connection: ultra
|
||||
});
|
||||
Services = new Meteor.Collection('services', {
|
||||
manager: ultra
|
||||
});
|
||||
collectionFuture.return();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var staticAppConfig;
|
||||
|
||||
try {
|
||||
if (process.env.APP_CONFIG)
|
||||
if (process.env.APP_CONFIG) {
|
||||
// TODO: parse env variables into a fake app config if we don't have one.
|
||||
staticAppConfig = JSON.parse(process.env.APP_CONFIG);
|
||||
} else {
|
||||
staticAppConfig = {
|
||||
packages: {
|
||||
'mongo-livedata': {
|
||||
url: process.env.MONGO_URL
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
Log.warn("Could not parse initial APP_CONFIG environment variable");
|
||||
};
|
||||
@@ -59,7 +69,10 @@ Galaxy.getAppConfig = function () {
|
||||
Galaxy.configurePackage = function (packageName, configure) {
|
||||
var appConfig = Galaxy.getAppConfig(); // Will either be based in the env var,
|
||||
// or wait for galaxy to connect.
|
||||
var lastConfig = null;
|
||||
var lastConfig = appConfig && appConfig.packages && appConfig.packages[packageName];
|
||||
if (lastConfig) {
|
||||
configure(lastConfig);
|
||||
}
|
||||
var configureIfDifferent = function (app) {
|
||||
if (!EJSON.equals(app.config && app.config.packages && app.config.packages[packageName],
|
||||
lastConfig)) {
|
||||
@@ -87,11 +100,12 @@ Galaxy.configurePackage = function (packageName, configure) {
|
||||
|
||||
|
||||
Galaxy.configureService = function (serviceName, configure) {
|
||||
|
||||
ultra.subscribe('servicesByName', serviceName);
|
||||
return Services.find({name: serviceName}).observe({
|
||||
added: configure,
|
||||
changed: configure
|
||||
});
|
||||
if (ultra) {
|
||||
ultra.subscribe('servicesByName', serviceName);
|
||||
return Services.find({name: serviceName}).observe({
|
||||
added: configure,
|
||||
changed: configure
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -22,11 +22,12 @@ _.extend(MongoInternals.RemoteCollectionDriver.prototype, {
|
||||
// only require Mongo configuration if it's actually used (eg, not if
|
||||
// you're only trying to receive data from a remote DDP server.)
|
||||
MongoInternals.defaultRemoteCollectionDriver = _.once(function () {
|
||||
// XXX kind of hacky
|
||||
var mongoUrl = (
|
||||
typeof __meteor_bootstrap__ !== 'undefined' &&
|
||||
Meteor._get(__meteor_bootstrap__,
|
||||
'deployConfig', 'packages', 'mongo-livedata', 'url'));
|
||||
var mongoUrl;
|
||||
Galaxy.configurePackage("mongo-livedata", function (config) {
|
||||
// This will keep running if mongo gets reconfigured. That's not ideal, but
|
||||
// should be ok for now.
|
||||
mongoUrl = config.url;
|
||||
});
|
||||
// XXX bad error since it could also be set directly in METEOR_DEPLOY_CONFIG
|
||||
if (! mongoUrl)
|
||||
throw new Error("MONGO_URL must be set in environment");
|
||||
|
||||
@@ -8,7 +8,10 @@ Npm.depends({connect: "2.7.10",
|
||||
useragent: "2.0.1"});
|
||||
|
||||
Package.on_use(function (api) {
|
||||
api.use(['logging', 'underscore', 'routepolicy', 'galaxy'], 'server');
|
||||
api.use(['logging', 'underscore', 'routepolicy'], 'server');
|
||||
api.use(['galaxy'], {
|
||||
unordered: true
|
||||
});
|
||||
api.export(['WebApp', 'main', 'WebAppInternals'], 'server');
|
||||
api.add_files('webapp_server.js', 'server');
|
||||
});
|
||||
|
||||
@@ -15,17 +15,6 @@ var send = Npm.require('send');
|
||||
WebApp = {};
|
||||
WebAppInternals = {};
|
||||
|
||||
var findGalaxy = _.once(function () {
|
||||
if (!('GALAXY' in process.env)) {
|
||||
console.log(
|
||||
"To do Meteor Galaxy operations like binding to a Galaxy " +
|
||||
"proxy, the GALAXY environment variable must be set.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
return DDP.connect(process.env['GALAXY']);
|
||||
});
|
||||
|
||||
// Keepalives so that when the outer server dies unceremoniously and
|
||||
// doesn't kill us, we quit ourselves. A little gross, but better than
|
||||
// pidfiles.
|
||||
@@ -447,42 +436,44 @@ var runWebAppServer = function () {
|
||||
console.log("LISTENING"); // must match run.js
|
||||
var port = httpServer.address().port;
|
||||
var proxyBinding;
|
||||
Galaxy.configurePackage('webapp', function (configuration) {
|
||||
if (proxyBinding)
|
||||
proxyBinding.stop();
|
||||
if (configuration && configuration.proxy) {
|
||||
proxyBinding = Galaxy.configureService(function (proxyService) {
|
||||
if (proxyService.providers.proxy) {
|
||||
var proxyConf;
|
||||
if (process.env.ADMIN_APP) {
|
||||
proxyConf = {
|
||||
securePort: null,
|
||||
insecurePort: 9414,
|
||||
bindHost: "localhost",
|
||||
bindPathPrefix: "/" + process.env.GALAXY_APP
|
||||
};
|
||||
} else {
|
||||
proxyConf = {
|
||||
// TODO: allow sitename to be a list.
|
||||
bindHost: configuration.proxy.sitename
|
||||
};
|
||||
Meteor.startup( function () {
|
||||
Galaxy.configurePackage('webapp', function (configuration) {
|
||||
if (proxyBinding)
|
||||
proxyBinding.stop();
|
||||
if (configuration && configuration.proxy) {
|
||||
proxyBinding = Galaxy.configureService(function (proxyService) {
|
||||
if (proxyService.providers.proxy) {
|
||||
var proxyConf;
|
||||
if (process.env.ADMIN_APP) {
|
||||
proxyConf = {
|
||||
securePort: null,
|
||||
insecurePort: 9414,
|
||||
bindHost: "localhost",
|
||||
bindPathPrefix: "/" + process.env.GALAXY_APP
|
||||
};
|
||||
} else {
|
||||
proxyConf = {
|
||||
// TODO: allow sitename to be a list.
|
||||
bindHost: configuration.proxy.sitename
|
||||
};
|
||||
|
||||
}
|
||||
Log("Attempting to bind to proxy at " + proxyService.providers.proxy);
|
||||
WebAppInternals.bindToProxy(_.extend({
|
||||
proxyEndpoint: proxyService.providers.proxy
|
||||
}, proxyConf));
|
||||
}
|
||||
Log("Attempting to bind to proxy at " + proxyService.providers.proxy);
|
||||
WebAppInternals.bindToProxy(_.extend({
|
||||
proxyEndpoint: proxyService.providers.proxy
|
||||
}, proxyConf));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var callbacks = onListeningCallbacks;
|
||||
onListeningCallbacks = null;
|
||||
_.each(callbacks, function (x) { x(); });
|
||||
}, function (e) {
|
||||
console.error("Error listening:", e);
|
||||
console.error(e.stack);
|
||||
var callbacks = onListeningCallbacks;
|
||||
onListeningCallbacks = null;
|
||||
_.each(callbacks, function (x) { x(); });
|
||||
}, function (e) {
|
||||
console.error("Error listening:", e);
|
||||
console.error(e.stack);
|
||||
});
|
||||
}));
|
||||
|
||||
if (argv.keepalive)
|
||||
|
||||
@@ -543,7 +543,6 @@ _.extend(Target.prototype, {
|
||||
// strong dependency on it, then ignore this edge.
|
||||
if (useOptions.weak && ! _.has(getsUsed, usedSlice.id))
|
||||
return;
|
||||
|
||||
if (onStack[usedSlice.id]) {
|
||||
buildmessage.error("circular dependency between packages " +
|
||||
slice.pkg.name + " and " + usedSlice.pkg.name);
|
||||
|
||||
Reference in New Issue
Block a user