-1

Im interested in running an Admin Meteor app and a Client Meteor App against a single Mongo database. Has anyone done this and or know how to do it both locally and in Production? How can this be configured, I understand there is a MONGO_URL that can be configured.

1 Answers1

4

You can set the global MONGO_URL to point to a specific running instance and DB by running the following command in the shell:

export MONGO_URL=mongodb://localhost:27017/your_db

(Replace localhost:27017 with whatever hostname / port # -- 27017 is default port that Mongo runs on -- and your_db with the database in question). This will overwrite the default meteor connection. You can see more about it in this question and the documentation; you can verify that it worked like so:

$ echo $MONGO_URL
  mongodb://localhost:27017/your_db // response

You can also control the connection for a given Collection using the connection option of Mongo.Collection(), but note that this will not work with third-party Collections (like those out of packages; e.g., the users Collection if using the Accounts package -- see this question for why that doesn't work).

As for locally vs. production, either way you'll need to have a MongoDB instance up and running (instructions in MongoDB's docs). You can do it locally using the MONGO_URL, but doing it in production will depend on your production setup -- if you have CLI access, you can follow the directions linked above from the Meteor docs.

Once you have the environment variable set up, it should be a simple matter of deploying both apps. You can find out more about how to do that from this Quora thread, but a short answer is that you can either deploy to different subdomains by managing IP addresses or deploy to different ports by configuring the PORT env variable, as in the documentation linked above:

env PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node main.js
Community
  • 1
  • 1
Carson Moore
  • 1,287
  • 1
  • 8
  • 9