I wanted to know how to go about getting a MongoHQ db to work on my localhost installation of Meter.
i tried using the settings.json method or the MONGO_URL=mongodb://user:pass#xxxx.mongohq.com:10061/xxxx when firing up meteor but both dont work and are probably the wrong way of doing it.
run it like this in your terminal within your project directory
MONGO_URL=mongodb://user:pass#xxxx.mongohq.com:10061/xxxx meteor
or
export MONGO_URL=mongodb://user:pass#xxxx.mongohq.com:10061/xxxx
meteor
Related
This is probably a very basic question, but this is my first time using Meteor + Heroku and I can't seem to figure out how to use the settings.json file after deploying a Meteor app (currently using heroku).
From my hours of research on web, it seems that in order to use the settings in a deployed app, I have to do...
export METEOR_SETTINGS="$(cat settings.json)"
At first I thought that this is meant to go to a boostrap file... Then I realized I was wrong when I started get reserved word errors (because of "export")
So... Where and how do I use this line? Am I suppose to use terminal to type this in? If so, how can I do that in Heroku?
Basically: heroku config:add METEOR_SETTINGS="$(cat settings.json)".
The heroku config:add... command didn't work for me, but I was able to use heroku's dashboard to set my environment variables. You can find the dashboard tab at:
https://dashboard.heroku.com/apps/yourAppName/settings, and then click on Reveal Config Vars
I have used meteorUp here sucesffuly to deploy my meteor project on my own host.
However I have no idea how to reset the database, or the entire project itself, like I can locally with the simple meteor reset command. I tried installing meteor on the server but there is no .meteor project so that command doesnt work. I looked in /opt/meteor folder but no meteor project exists.
If you need to reset the data. You need to login to the server. login to mongodb with mongo meteor.
Then do db.dropDatabase() to delete the DB.
If you need to change the app, simple redeploy should work.
BTW: Do you not use MongoDB this way for a production app.
If you are using mup or mupx try:
Login to your server:
$ ssh <user>#<server-ip>
Login into mongo shell
$ docker exec -it mongodb mongo <app-name>
Drop db
> db.dropDatabase()
Is this what you are looking for?
mup reconfig
Based on the doc for it:
This will also restart the app [without re-deploying], so you can use it for that purpose
even if you didn't change the configuration file.
I don't have enough points to comment yet, but to add onto Arunoda's response, you might want to
use [name of app database]
before you
db.dropDatabase()
And if you don't know what the name is you can also
show databases
If you used mup, the database will generally be the same name as your app.
I am using Ubuntu 13.10 lokal and running my meteorJs app on it. My MongoDB is an external DB (modulus.io).
I set my mongoDb in my console like this:
sudo MONGO_URL='mongodb://login#db' meteor
Works fine.
But everytime when I restart my lokal meteorJs App this settings seems to be resetet! So everytime when I restart my App I have to set the enviroment variable again and again ...
Is there a way to set this variable permanent in my meteorJs App so I dont have to re set it again and again.
Fast solution:
Create startup.sh and insert:
export MONGO_URL='mongodb://login#db'
meteor
sh startup.sh
Another way to set environment variables that are accessed from within your app, is to put the following in your server code, i.e. for HTTP_FORWARDED_COUNT:
process.env.HTTP_FORWARDED_COUNT = 1
Doing it programmatically like this does not work for variables that need to be read during the app startup process, however - such as the MongoDB URL.
So, I have started to test Meteor on a Nitrous.io box in the cloud. I used to enter a test record by typing it directly into the Chrome browser console, like:
Projects.insert({name:'First Project',client:'Project Central',duedate:new Date(),status:'On Hold'});
However, that does not work on Nitrous.
So, how do I add a test record in my meteor collection to work on?
Who can help me in the right direction? Much appreciated.
After you run meteor run in a Nitrous.io console,
open up another console and run meteor mongo.
Then you can type in a db.Projects.insert(...) or other mongoDB command.
There might be the case if you removed insecure package, insert will not work from browser client.
Check if the 'insecure' package installed or not using following command
meteor list --using
which will list the packages which are used by the meteor app.
I am trying a test to move all my development to Nitrous.io IDE, but with limited space in my Nitrous box I want to permanently host my Mongo databases at MongoHQ.com. Currently each day I need to set my MONGO_URL by running:
export MONGO_URL='mongodb://<user>:<pass>#paulo.mongohq.com:12345/<db>'
If I fire up another console or logout of Nitrous my MONGO_URL needs to set again.
How can I set the development MONGO_URL for good per meteor app? I cannot find a config file anywhere.
Nitrous support helped me find a quick solution. Just wanted to answer it here for others with the same issue.
Open ~/.bash_profile and enter your DB information.
example:
export MONGO_URL='mongodb://jimmy:criket#paulo.mongohq.com:12345/mynitrobox'
Next in the console run source ~/.bash_profile to load the settings.
This sets the DB for your entire node.js box, not individual meteor apps, so you may want to structure your Mongo collections accordingly with subcollections.
you can do this in one line like so:
MONGO_URL='mongodb://<user>:<pass>#paulo.mongohq.com:12345/<db>' meteor
I don't know much about Nitrous.io but in AWS EC2 I have an upstart job that runs this for me when the server starts.
I gist'd my approach a while back, I've since changed it a bit but this still works:
https://gist.github.com/davidworkman9/6466734
I don't know that this will help you in Nitrous.io though, good luck!