Changes to how Meteor.settings is filled on Galaxy

(a) Prefer $APP_CONFIG over $METEOR_SETTINGS

(b) Allow $APP_CONFIG's settings field to be a string which we
parse (which will be the default soon)
This commit is contained in:
David Glasser
2014-01-09 16:57:49 -08:00
parent 0b76997e3d
commit e445a4af6a

View File

@@ -4,21 +4,34 @@ Meteor = {
};
Meteor.settings = {};
if (process.env.METEOR_SETTINGS) {
if (process.env.APP_CONFIG) {
// put settings from the app configuration in the settings. Don't depend on
// the Galaxy package for now, to avoid silly loops.
try {
var appConfig = JSON.parse(process.env.APP_CONFIG);
if (!appConfig.settings) {
Meteor.settings = {};
} else if (typeof appConfig.settings === "string") {
Meteor.settings = JSON.parse(appConfig.settings);
} else {
// Old versions of Galaxy may store settings in MongoDB as objects. Newer
// versions store it as strings (so that we aren't restricted to
// MongoDB-compatible objects). This line makes it work on older Galaxies.
// XXX delete this eventually
Meteor.settings = appConfig.settings;
}
} catch (e) {
throw new Error("Settings from app config are not valid JSON");
}
} else if (process.env.METEOR_SETTINGS) {
try {
Meteor.settings = JSON.parse(process.env.METEOR_SETTINGS);
} catch (e) {
throw new Error("Settings are not valid JSON");
}
} else if ( process.env.APP_CONFIG) {
// put settings from the app configuration in the settings. Don't depend on
// the Galaxy package for now, to avoid silly loops.
try {
Meteor.settings = JSON.parse(process.env.APP_CONFIG).settings || {};
} catch (e) {
throw new Error("Settings are not valid JSON");
}
}
// Push a subset of settings to the client.
if (Meteor.settings && Meteor.settings.public &&
typeof __meteor_runtime_config__ === "object") {