Reputation: 377
I was breaking out some of the admin/management functionality from a Meteor app into another new one to cut down client app size/help restrict access. I also have MongoDB installed separately on localhost and in production.
I've been able to run each app on separate ports and to connect to the DB passing environment variables as I start the apps:
# App 1
MONGO_URL=mongodb://localhost:27107/appDB meteor
# App 2
MONGO_URL=mongodb://localhost:27107/appDB meteor --port 4000
Of course, I'd like to use settings.json
in the project root to pass these variables in rather than having to specify them (here's the settings.json
for App 2):
{
"env": {
"PORT": 4000,
"MONGO_URL": "mongodb://localhost:27017/appDB"
}
}
And using meteor run --settings settings.json
to pass these variables in. However, Meteor won't recognise the settings file. Any ideas where I might've gone wrong?
Update 1:
@Apendua was kind enough to let me know that settings.json
simply doesn't support this behaviour yet. Setting up bash aliases instead.
Update 2: @AshHimself pointed out that Galaxy can recognise environment variables in this fashion, but the core Meteor docs weren't terribly clear if this works in a local environment.
Upvotes: 5
Views: 8598
Reputation: 2458
It's not as fancy as a shell script, but...this one liner alias works too.
alias <myapp>="export MONGO_URL=mongodb://<mongohost>:<port>/<database>; meteor run"
Of course, sub everything in brackets to your taste and rejoice.
Upvotes: 0
Reputation: 31
This worked for me very well. The only changes I would make is just adding execution permissions only, and I dumped the .sh
off the filename.
echo 'MONGO_URL=mongodb://localhost:27017/meteorprojectname meteor run' > run
sudo chmod +x run
./run
Upvotes: 0
Reputation: 2200
I run my Meteor app with local MongoDB with bash script.
Go to your Meteor project directory and write this in your command line (BASH):
echo 'MONGO_URL=mongodb://localhost:27017/meteorprojectname meteor run' > run.sh
Change permissions of the script so you can run it without sudo:
sudo chmod 777 run.sh
And now you can just run your project with command:
./run.sh
More info: http://meteor.hromnik.com/blog/meteor-run-without-creating-local-mongo-database
Upvotes: 2