24

How would I use a (live running) MongoDB to develop another meteor app? I tried modifying (.meteor/server/server.js) and specifying MONGO_URL to no avail before running meteor.

This is without using the bundled MongoDB, it has to be a separate/custom one (basically of another meteor instance).

This can be done with the deploy method but what about the normal meteor run during development?

UPDATE: this does work however the client side implementation seems a bit glitchy

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
Tarang
  • 75,157
  • 39
  • 215
  • 276
  • I got the same question, but cannot find the answer here. Actually I didn't find ./meteor/server folder, but server.js in ./meteor/local/build/server/ will always be rebuild when you restart meteor server. – Mason Zhang Jul 28 '12 at 12:17

2 Answers2

30

As mentioned in the Unofficial Meteor FAQ, you can invoke Meteor with the MONGO_URL environment variable set to the desired instance:

MONGO_URL=mongodb://localhost:27017 meteor

If your MongoDB handles multiple databases, you can indicate which one to use by appending it to the URL:

MONGO_URL=mongodb://localhost:27017/mydb meteor

You can even prevent Meteor from starting a local Mongo instance in development by running:

MONGO_URL=none meteor
Blackcoat
  • 3,280
  • 30
  • 25
  • 2
    Is there a way to store the variable somewhere in the project? Always typing `MONGO_URL=...` to spin up meteor seems stupid. Would be nice if it could be picked up somehow while just using `meteor run`. (I know, first world problems..) – frhd Oct 17 '14 at 12:59
  • 2
    @archiehicox No need. Just put that env-variable to your `~/.profile` file for user-wide propagation, or inside `/etc/environment` for system-wide propagation. – Gelmir Nov 05 '14 at 10:01
  • 2
    @Shehi That's a good way. You're right, it's not project-specific. – frhd Nov 05 '14 at 12:54
10

I found that you should not forget to specify the database to connect to. In my case, I wanted a second Meteor instance to connect to the development MongoDB server from a first instance.

Meteor uses the HTTP port +2 for a development MongoDB, and database 'meteor', so the correct way to start the second server is:

MONGO_URL=mongodb://localhost:3002/meteor meteor --port=3800
konrad
  • 3,340
  • 1
  • 27
  • 26
  • 2
    It's actually HTTP port +1 (at least now it is). You can verify this by doing a `meteor mongo` call to connect to the default database. So the default database `mongodb://localhost:3001/meteor` – evolross Jan 04 '17 at 23:12