mongodb - 2 Meteor Apps on one database -
im interested in running admin meteor app , client meteor app against single mongo database. has done , or know how both locally , in production? how can configured, understand there mongo_url can configured.
you can set global mongo_url
point specific running instance , db running following command in shell:
export mongo_url=mongodb://localhost:27017/your_db
(replace localhost:27017
whatever hostname / port # -- 27017 default port mongo runs on -- , your_db
database in question). overwrite default meteor connection. can see more in this question , the documentation; can verify worked so:
$ echo $mongo_url mongodb://localhost:27017/your_db // response
you can control connection given collection using connection
option of mongo.collection()
, note not work third-party collections (like out of packages; e.g., users collection if using accounts package -- see this question why doesn't work).
as locally vs. production, either way you'll need have mongodb instance , running (instructions in mongodb's docs). can locally using mongo_url, doing in production depend on production setup -- if have cli access, can follow directions linked above meteor docs.
once have environment variable set up, should simple matter of deploying both apps. can find out more how this quora thread, short answer can either deploy different subdomains managing ip addresses or deploy different ports configuring port env variable, in documentation linked above:
env port=3000 mongo_url=mongodb://localhost:27017/myapp node main.js
Comments
Post a Comment