7

Typically when developing I would use meteor run --settings settings.json. This works fine and can view the settings in the browser with Meteor.settings on the console.

I am now build for production, using meteor build, I've looked at the documentation and there is nowhere to add settings during the build process.

So the build runs and I have my .tar.gz file, it's loaded to production and then I untar/compress the folder and run the start script.

It enters the program with npm start and the package.json section looks like this (ignore the stop script);

{
  "name": "myapp",
  "scripts": {
    "start": "node main.js --settings settings.json",
    "stop": "killall node"
  }
}

When I look at my app it is not collecting these settings. It is as if when bundled it doesn't expect the arguements. I also tried using forever beforehand, but I had no joy with this either.

Any help would appreciated, start to wish I never bothered with Meteor :)

1 Answer 1

3

You can refer to Meteor Guide > Production > Deployment and Monitoring > Environment variables and Settings

Settings. These are in a JSON object set via either the --settings Meteor command-line flag or stringified into the METEOR_SETTINGS environment variable.

As for setting environment variables, if you use a 3rd party host, you may have a GUI or CLI to define them.

Otherwise, you should have plenty resources including on SO:

In short, it should look like:

METEOR_SETTINGS='{"key":"value"}' node main.js

You can also try the bash cat command to extract the content of a file: $(cat settings.json)

6
  • Excellent! They need to go before node? (I was just looking at the cat option) Commented Aug 17, 2016 at 15:24
  • You don't happen to know how I can do this with forever while you here do ya :) Commented Aug 17, 2016 at 15:43
  • For the record, just found that example on Docs: stackoverflow.com/documentation/meteor/4198/… (not sure it is in the appropriate topic though)
    – ghybs
    Commented Aug 19, 2016 at 20:39
  • @ghybs after all these years, I'm still supporting a legacy meteor app and wanted to see an example of the meteor settings after the app as been converted to node. The SO docs has been deactivated so I cannot see the example you referenced. Any chance you can post it here/somewhere?
    – Aaron
    Commented Feb 14, 2021 at 2:04
  • 1
    Hi @Aaron, not exactly sure what you need besides what is posted in the above answer? I do have some Meteor apps, and still use the above technique without any issue: METEOR_SETTINGS="$(cat /path/to/settingsProd.json)" node main.js (in linux).
    – ghybs
    Commented Feb 14, 2021 at 2:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.