0

I am currently deploying to Digital Ocean using Meteor Up. If I don't specify a MONGO_URL in the mup.json, can I get the value from the command line while the website is running, i.e. I don't want to shutdown the site?

If I go to the app directory and run meteor mongo --url, I get the following error:

mongo: Meteor isn't running a local MongoDB server.

This command only works while Meteor is running your application
locally. Start your application first. (This error will also occur if
you asked Meteor to use a different MongoDB server with $MONGO_URL when
you ran your application.)

If you're trying to connect to the database of an app you deployed
with 'meteor deploy', specify your site's name with this command.

Even if I run the app from the app directory, it will only give the localhost MONGO_URL. I need the MONGO_URL for the deployed app.

I have also taken a look at a similar question as suggested by some of the answers. I disagree that it is "impossible" to get the MONGO_URL without some other program running on the server. It's not as if we are defying the laws of physics here, folks. Fundamentally, there should be a way to access it. Just because no one has yet figured it out doesn't mean it is impossible.

Community
  • 1
  • 1
FullStack
  • 5,902
  • 4
  • 43
  • 77
  • Looks like a duplicate of [Meteor Up deployment, can't use meteor mongo --url](http://stackoverflow.com/questions/23786647/meteor-up-deployment-cant-use-meteor-mongo-url), and apparently not possible. – Dan Dascalescu Oct 26 '14 at 21:30
  • Thanks for pointing out the similar question. It is certainly useful. I have edited my question to specify that I don't want to use Python, which is involved in the solution provided there. – FullStack Oct 27 '14 at 03:59

2 Answers2

1

meteor mongo --url should return the URL.

Try opening another shell in the app directory and running that command.

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
  • Unfortunately, I get an error when I tried your suggestion: "mongo: Meteor isn't running a local MongoDB server." I have updated my question to reflect this. Do you have any more suggestions? Thank you for your kind response. – FullStack Oct 26 '14 at 14:58
  • Haven't worked with Meteor Up (I've rolled my own start script using pm2). Meteorpedia has a [page on accessing the database](http://www.meteorpedia.com/read/Mongo) that should be improved. – Dan Dascalescu Oct 26 '14 at 21:32
0

Meteor Up packages your app in production mode with meteor build so that it runs via node rather than the meteor command line interface. Among other things, this means meteor foo won't work on the remote server (at least not by default). So what you're really looking for is a way to access mongo itself remotely.

I recently set up mongo on an AWS EC2 instance and listed some lessons learned here: https://stackoverflow.com/a/28846703/2669596. Some details of how you do it are going to be different on Digital Ocean, but these are the main things you have to take care of once mongo itself is installed:

  • Public IP/DNS Address: This is probably fine already since you can deploy to the server.
  • Port Security Rules: You need to make sure port 27017 is open for TCP access, at least from your IP address. MongoDB also has an http interface you can set up; if you want to use that you'll need to open 28017 as well.
  • /etc/mongod.conf (file location may differ depending on Linux flavor):
    • Uncomment port=27017 to make sure you have the default port (I don't think this is actually necessary, but it made me feel better and it's good to know where to change the default port...).
    • Comment out bind_ip=127.0.0.1 in order to listen to external interfaces (e.g. remote connections).
    • Uncomment httpinterface=true if you want to use the http interface.
    • You may have to restart the mongod host via sudo service mongod restart. That's a problem if you can't have downtime, but I don't know of a way around that if you change the config file.
  • Create User: You need to create an admin and/or user to access the database remotely.

Once you've done all of that, you should be able to access the database from your local machine (assuming you have the mongo client installed locally) by running mongo server.url.com:27017/mup-app-name -u username -p where server.url.com is the URL or IP address of your remote server, mup-app-name is the appName parameter from your mup.json file, username is the user you created to access the database, and you'll be prompted for that user's password after you run the command (or you could put it after -p on the same line, depending on the password).

There may also be a way to do this by setting up nginx to reverse-proxy 127.0.0.1:27017 on your remote server, but I've never done it and that's just me speculating.

Community
  • 1
  • 1
Nick Benes
  • 1,334
  • 15
  • 14