Trying to set up a Meteor on an AWS/EBS (Amazon Web Services, Elastic Beanstalk) environment.
A Meteor dev-run can be passed a command line flag: --settings settings.json
where settings.json
is a file containing server/client key/value configs (as properly-formatted JSON).
Instead of passing the config file in command line, Meteor's deployment uses a METEOR_SETTINGS
environment variable. If provided it is expected to contain a json document such as contents of settings.json
, for example:
$ METEOR_SETTINGS=$(cat settings.json)
$ echo $METEOR_SETTINGS
{ "public": { "s3path": "https://d2v4p3rms9rvi3.cloudfront.net" } }
The problem is that when I set the value of METEOR_SETTINGS
to this value in the EBS console:
AWS/EBS discards the quotes, escapes the slashes (as seen in screenshot), and sends Meteor:
{public:{s3path:https://d2v4p3rms9rvi3.cloudfront.net}}
As indicated by the node start up error:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
> [email protected] start /var/app/current
> node main.js
/var/app/current/programs/server/boot.js:283
}).run();
^
Error: METEOR_SETTINGS are not valid JSON: {public:{s3path:https://d2v4p3rms9rvi3.cloudfront.net}}
at packages/meteor/packages/meteor.js:21:1
at Package (packages/meteor/packages/meteor.js:42:1)
at /var/app/current/programs/server/packages/meteor.js:1277:4
at /var/app/current/programs/server/packages/meteor.js:1286:3
at /var/app/current/programs/server/boot.js:242:10
at Array.forEach (native)
at Function._.each._.forEach (/var/app/current/node_modules/underscore/underscore.js:79:11)
at /var/app/current/programs/server/boot.js:137:5
Bumping against this problem I tried all sorts of variations for the JSON object in the value field:
escaping the quotes, enclosing the entire json part with single quotes, replacing double-quotes with single-quotes, and other attempts - neither solved it.
Question is:
How can METEOR_SETTINGS
be set so that Meteor rcv & parse it correctly?
Note: one of the requirements is that the same build deploys to dev, staging and production environments. Configs need to be set separately for each environment thus if there's another way to inject the settings into the EBS environment w/o modifying the build that will also solve it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…