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.
Related
When developing with Meteor locally, one execute meteor reset locally to refresh the database.
Can one run this command on a production level app deployed on Bluemix without digging into the Mongo console?
The meteor reset command actually deletes the local mongo database files in .meteor/local. Since the database isn't stored in the application container when running in Cloud Foundry, there isn't an equivalent operation as a one liner.
Seems like your only option is to retrieve the connection credentials from your application cf env appname and then stop the application, connect with the mongo command line, and use one of the methods described in this answer to clean your data out.
I develop Meteor application on my local computer, and deploy it to meteor.com. I want to have an opportunity to use remote production MongoDB database for local development.
So, I get url to my DB with meteor mongo --url myapp.meteor.com, then I add it to my MONGO_URL environment variable:
export MONGO_URL=mongodb://client-5345a08c:5f63edff-8cec-a818-7f35-c05021bb6d91#production-db-d1.meteor.io:27017/34377_ru
The inconvinience is that this url is invalid in one minute, so I need to generate another one and modify my MONGO_URL every time I want to start my application. I suspect some permanent url to my MongoDB is out there. I ran meteor mongo myapp.meteor.com and noticed greeting:
MongoDB shell version: 2.4.9
connecting to: production-db-d1.meteor.io:27017/34377_ru
I tried to use this url:
export MONGO_URL=mongodb://production-db-d1.meteor.io:27017/34377_ru
and even
export MONGO_URL=mongodb://myneteorcomusername:mymeteorcompassproduction-db-d1.meteor.io:27017/34377_ru
but I had no luck.
Are there ways to simplify my workflow and make meteor use my remote database by default?
I guess for scaling purposes, there is no dedicated mongo ever for each subdomain. I could be wrong so better ask this question over at the Meteor Talk Google group.
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.
Setting an environment variable on the localhost is done using export.
e.g. export PORT=80
My Question is how to set an environment var for the remote meteor server.
I am using Meteor's free hosting service and deploy using meteor deploy appname, and therefore have no ssh access to the remote command line.
I'd like to set DISABLE_WEBSOCKETS to true.
I've looked at the list of possible meteor commands and haven't found one which relates to setting env vars.
You do it the same way when you run your server e.g, you don't have to use export you can just put the environment variables in the line you use to start meteor.
PORT=80 node main.js
or if you use forever
PORT=80 forever start main.js
or even with meteor
DISABLE_WEBSOCKETS=TRUE meteor
I'm a bit confused about your setup, by remote meteor server you mean a production environment? You shouldn't use the meteor command in production as it is not optimized this way and performance would be very significantly affected.
Meteor gets the environment variables using process so whatever you use to start the process you can pass the environment variables to it using the typical terminal/bash/shell/ssh that you used to start the process up.
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