Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Meteor Build under Node with settings argument

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

like image 644
Matt The Ninja Avatar asked Aug 17 '16 14:08

Matt The Ninja


Video Answer


1 Answers

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:

  • Node.js: Setting Environment Variables
  • How can I set an environmental variable in node.js?
  • https://themeteorchef.com/snippets/making-use-of-settings-json/

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)

like image 166
ghybs Avatar answered Nov 09 '22 20:11

ghybs