From e445a4af6aaa39aabce12edbe4a2a93fc30e6745 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 9 Jan 2014 16:57:49 -0800 Subject: [PATCH] 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) --- packages/meteor/server_environment.js | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/meteor/server_environment.js b/packages/meteor/server_environment.js index 18cbbaa550..6d6a2ff4e7 100644 --- a/packages/meteor/server_environment.js +++ b/packages/meteor/server_environment.js @@ -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") {