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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With