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 :)

Matt The Ninja
  • 2,641
  • 4
  • 28
  • 58

1 Answers1

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)

Community
  • 1
  • 1
ghybs
  • 47,565
  • 6
  • 74
  • 99
  • Excellent! They need to go before node? (I was just looking at the cat option) – Matt The Ninja Aug 17 '16 at 15:24
  • You don't happen to know how I can do this with forever while you here do ya :) – Matt The Ninja Aug 17 '16 at 15:43
  • For the record, just found that example on Docs: https://stackoverflow.com/documentation/meteor/4198/environment-detection/14700/specifying-app-parameters-with-meteor-settings (not sure it is in the appropriate topic though) – ghybs Aug 19 '16 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 Feb 14 '21 at 02: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 Feb 14 '21 at 02:38
  • I was able to make a script after all. Deploying the Docker/Meteor container to Azure. Everything works nicely. Thank you. – Aaron Feb 24 '21 at 16:03