Using Meteor settings.json to connect to local MongoDB

I pulled some of the admin / management functions from the Meteor app into another new one to reduce the size of the client application / reduce access restriction. I also have MongoDB installed separately on localhost and in production.

I could run each application on separate ports and connect to database environment variables when starting applications:

# App 1 MONGO_URL=mongodb://localhost:27107/appDB meteor # App 2 MONGO_URL=mongodb://localhost:27107/appDB meteor --port 4000 

Of course, I would like to use settings.json in the root of the project to pass these variables instead of specifying them (here 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. However, Meteor does not recognize the settings file. Any ideas I might have made a mistake in?

Update 1: @Apendua was kind enough to tell me that settings.json just doesn't support this behavior. Instead of bash aliases.

Update 2: @AshHimself pointed out that Galaxy can recognize environment variables this way, but the main Meteor docs werenโ€™t terribly clear if it worked in a local environment.

+5
source share
2 answers

I am running my Meteor application with local MongoDB using a bash script.

Go to the Meteor project directory and write this on the command line (BASH):

 echo 'MONGO_URL=mongodb://localhost:27017/meteorprojectname meteor run' > run.sh 

Change the permissions of the script so that you can run it without sudo:

 sudo chmod 777 run.sh 

And now you can just start your project with the command:

 ./run.sh 

Additional information: http://meteor.hromnik.com/blog/meteor-run-without-creating-local-mongo-database

+2
source

It worked very well for me. The only changes I would make were to simply add execute permissions, and I dumped .sh from the file name.

 echo 'MONGO_URL=mongodb://localhost:27017/meteorprojectname meteor run' > run sudo chmod +x run ./run 
0
source

All Articles