yoK0
yoK0

Reputation: 325

Separate mongo databases for meteor apps

Say I host ten different meteor apps on one server and mongoDB. The applications have same-named collections, so I want to use separate databases for each one of them.
How would I achieve this ? Exporting MONGO_URL will work for one app only, right?

Upvotes: 0

Views: 156

Answers (1)

Martin J.
Martin J.

Reputation: 5108

I assume you have some sort of script to start each meteor application, for instance:

#!/bin.bash
cd /path/to/my/app
meteor

Then, you can just export the MONGO_URL variable as part of each meteor application's startup script, and each application will run with its own value for the MONGO_URL variable.

With that in mind, the startup script for app1 becomes:

#!/bin.bash
cd /path/to/my/app1
export MONGO_URL=mongodb://localhost:27017/app1
meteor

and the startup script for app2 is:

#!/bin.bash
cd /path/to/my/app2
export MONGO_URL=mongodb://localhost:27017/app2
meteor

Side-note: what I said applies even if you don't have startup scripts. If you start your applications by hand in the terminal, you can just do:

> cd /path/to/my/app1
> export MONGO_URL=mongodb://localhost:27017/app1
> meteor &
> ...
> cd /path/to/my/app2
> export MONGO_URL=mongodb://localhost:27017/app2
> meteor &

Upvotes: 1

Related Questions