How do I specfiy a MongoHQ database when deploying Meteor app?

不打扰是莪最后的温柔 提交于 2019-12-21 07:36:53

问题


I would like to use my own MongoHQ database to use when deploying a Meteor app using meteor deploy. The documentation explains how to do this when deploying and running on a machine I control:

$ PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js

But the documentation seems a bit sparse on how to do this with meteor deploy. Is it possible?

EDIT: I tried following http://docs.meteor.com/#meteor_settings and added a settings.json file and put in it:

{"MONGO_URL" : "mongodb://user:pass@mongohq.com:10000/mydatabase"} 

then deployed with

meteor deploy myappname.meteor.com --settings settings.json

but the deployed version doesn't seen to be using my database


回答1:


I ended up deploying to Heroku instead using the buildpack. Then I could set the variables using the heroku configs.




回答2:


A quick scan of the codebase reveals this line in remote_collection_driver.js:

Meteor._RemoteCollectionDriver = new Meteor._RemoteCollectionDriver(process.env.MONGO_URL);

I'm sure if you hacked that to point where you wanted it, it would work. If that's too much of a kluge (for instance, if you plan on ever updating Meteor versions) you could experiment with trying to change Meteor._RemoteCollectionDriver or process.env.MONGO_URL early enough, from your own code (without hacking into Meteor's js directly). Good luck.



来源:https://stackoverflow.com/questions/14328704/how-do-i-specfiy-a-mongohq-database-when-deploying-meteor-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!