[SOLVED] Running multiple Meteor apps at the same time locally


#1

On Meteor 1.5, I need to run (2) copies of the same codebase (same directory to start), on (2) different ports, that talk to (1) database, at the same time on my local box.

I tried to test this:

.

If I just run npm run admin in the /meteors/test-app directory it starts up fine with data in the database and the proper structure.

// package.json:

"admin": "meteor --port 3000 --settings .config/development/settings.json",
"client": "meteor --port 3002 --settings .config/development/settings.json",

.

If I type in meteor mongo in the /meteors/test-app directory (the now running app) I get the following:

MongoDB shell version: 3.2.12
connecting to: 127.0.0.1:3001/meteor

.

I stop the app and now If I try to specifiy that same localhost and port with a MONGO_URL I get an error when trying to run:

"admin": "MONGO_URL=mongodb://localhost:3001/meteor meteor --port 3000 --settings .config/development/settings.json",

.

MongoError: failed to connect to server [localhost:3001] on first connect

.

This is my first problem, and without getting past it, I don’t see how I can run with (1) meteor application directory on (2) different ports yet still point to (1) database.


Here’s the SO question on this: https://stackoverflow.com/questions/44953196/running-multiple-meteor-apps-at-the-same-time-locally

The original question on Github: https://github.com/meteor/meteor/issues/6532#issuecomment-313290558


#2

If you specify a MONGO_URL Meteor does not start Mongo for you - it expects it to be already running.


#3

I figured it out. I didn’t have a local mongo instance running, I always just used the instance supplied with Meteor. I did a brew install of Mongo 3.2, started it up, pointed to mongodb://localhost:27017/meteor and it connected.


#4

maybe add “[SOLVED}” to your title


#5

In other words add this to your package.json and start up two instances of your app.

"start": "meteor run --settings settings-development.json",
"start2": "MONGO_URL=mongodb://localhost:3001/meteor meteor run --port 3030 --settings settings-development.json"