0

I have two different meteor apps. app1 running on 3000 and app2 running on 3002. So my question is both app1 and app2 should use same Database. I tried connecting app2 with "export MONGO_URL=mongodb://localhost:3001/app1" but went fruitless.

How would I be able to accomplish this?

Ajith Pai
  • 34
  • 5
  • possible duplicate of [How can I share MongoDB collections between Meteor apps?](http://stackoverflow.com/questions/13115723/how-can-i-share-mongodb-collections-between-meteor-apps) – Blakes Seven Sep 03 '15 at 10:32
  • Which of course means the real answer here is to use a "separate and shared" instance of MongoDB for both applications rather than try to connect one application to the other app's datbase instance. – Blakes Seven Sep 03 '15 at 10:33
  • I used "MONGO_URL=mongodb://localhost:27017/my_db" to connect both apps, but not connecting. – Ajith Pai Sep 03 '15 at 11:58
  • You need to start an "independant" MongoDB. In the real world this is what you do. You will **never** deploy both MongoDB and "multiple" apps ( or even one ) on the same server instance. Learn the lesson please. – Blakes Seven Sep 03 '15 at 12:02

2 Answers2

0

The standard database meteor creates is called meteor, so I think you should start your second meteor instance with:

MONGO_URL=mongodb://localhost:3001/meteor meteor -p 3002
japetheape
  • 1,900
  • 2
  • 12
  • 6
0

On Windows 10:

  1. In App-1 start with meteor
  2. Open second Powershell: cd path/to/APP-1
  3. Enter: meteor mongo
  4. In Line> connecting to: copy complete mongodb-URL something like: mongodb://127.0.0.1:3001/meteor?compressors=disabled&gssapiServiceName=mongodb
  5. exit from mongo-shell
  6. cd path/to/APP-2
  7. Create a meteor_start.bat file 8.Open with Editor meteor_start.bat type (!!!Attention & -> ^& in Mongo-URL): SET MONGO_URL=mongodb://127.0.0.1:3001/meteor?compressors=disabled&gssapiServiceName=mongodb & meteor --port 3500
  8. Save meteor_start.bat
  9. Powershell > cd path/to/APP-2
  10. enter cmd
  11. enter meteor_start.bat

Result: App-1 running at localhost 3000 App-2 running at localhost 3500

App-1 & App2 using same local mongodb at mongodb://127.0.0.1:3001

Have Fun