admin管理员组

文章数量:1206400

Rather than starting Meteor with the flag --settings settings.json

mrt --settings settings.json

Is it possible to define Meteor.Settings automatically on startup by just running

mrt

Rather than starting Meteor with the flag --settings settings.json

mrt --settings settings.json

Is it possible to define Meteor.Settings automatically on startup by just running

mrt
Share Improve this question asked Jan 9, 2014 at 2:20 NyxynyxNyxynyx 63.6k163 gold badges505 silver badges855 bronze badges 1
  • what about nowadays? – rodrigocprates Commented Sep 25, 2015 at 22:49
Add a comment  | 

3 Answers 3

Reset to default 11

Nowadays the command should be meteor (no more mrt):

meteor --settings settings.json

To automatically load settings file, I like the method suggested on "The Meteor Chef" that exploits npm:

Creating a file package.json in the project root:

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "start": "meteor --settings settings.json"
  }
}

We can start meteor with:

npm start

DEV/PROD

Also it is possible to have two or more scripts for two or more settings:

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "meteor:dev": "meteor --settings settings-dev.json",
    "meteor:prod": "meteor --settings settings-prod.json"
  }
}

Then:

npm run meteor:dev

or

npm run meteor:prod

(note that here we have to add the run command, not required with the "special" script start)

For dev, use an alias

alias mrt='mrt --settings settings.json'

or

alias mrts='mrt --settings settings.json'

remove it with unalias mrts

When you want it to be permanent, put it in ~/.bashrc or ~/.bash_profile

Alternatively, meteor accepts an environment variable (useful for production)

METEOR_SETTINGS = `cat path/to/settings.json`
export METEOR_SETTINGS

If you don't want to fiddle with aliases, you could create a bash script in the root directory of a specific project, like so:

dev.sh:

#!/bin/bash
meteor --settings ./config/development/settings.json

And just run it from the meteor project directory with:

./dev.sh

If you get -bash: ./dev.sh: Permission denied just do:

chmod +x ./dev.sh

If you use other services you could start them before meteor like so:

#!/bin/bash
sudo service elasticsearch start
meteor --settings ./config/development/settings.json

本文标签: javascriptAutomatically load settingsjson on starting MeteorjsStack Overflow