Issue with "Meteor mongo" command when connected to separate Mongo Instance - meteor

When running the "parties" example locally, if I first specify my MONGO_URL to use an already existing mongo instance meteor mongo reports that meteor isn't running, even though it is and even though it is connecting just fine to a separate mongo instance.
If you run the meteor app without specifying a separate MONGO_URL, no problems meteor mongo works as expected
Now I have also tried setting the MONGO_URL before running meteor mongo to no avail. I haven't tried deploying the app to see what would happen.
The one other attempt to troubleshoot is after running the app, I try to connect using meteor mongo with the --url localhost:27017 flag it asks for a Password:. This is supposed to give me a URL to connect to the database instance, and the request for a Password isn't mongo either, since
a) I don't have authentication enabled on my local instance
b) Even if the local instance isn't running and you run meteor mongo it still asks for a password.
In the meteor documentation it notes under meteor mongo:
For now, you must already have your application running locally with meteor run. This will be easier >in the future.
Is this what they mean?
Obviously, it is isn't crucial that I have shell access from meteor to my local instance since I can always get shell access by just typing mongo, but my concern has to do with deployment, and should I want shell access then, this might be a problem.

Meteor mongo is meant to connect to the mongo database meteor runs when it runs in development, i.e that is run with meteor run, without a MONGO_URL or in deployment mode on meteor.com
This means it can't access other mongodbs, for instance if you specify MONGO_URL. meteor mongo will actually look for the running process id of the mongodb running in the .meteor directory of your project.
The reason meteor mongo --url localhost:27017 asks for a password is its attempting to connect to meteor.com hosting (if you deployed your app via meteor deploy), so if you deployed your app to test.meteor.com you could access its mongodb uri via meteor mongo test.meteor.com. If a password is set it will ask for that password.
To access your local mongodb collection you would have to look at the /bin directory of your mongodb instance or use mongo --dbpath xxx where xxx is where your database is installed. (Or as you mentioned to use mongo)

Related

Meteor command showing ctrl-c option to stop while trying to run the app

I am new to meteor. When i try to run meteor app in cmd prompt is showing ctrl-c option to stop the app.
When I enter y or n option the app gets stopped and I am unable to connect with mongo db. It is showing an error that meteor is not running a local mongodb server. It is mentioned to start the app first with meteor command.
Someone please help me
Thanks
yes, that's right. when running locally, the mongodb instance attached to your application is started when you run meteor, and stops running when you stop meteor.
in a real production application, you would have a mongo instance that is separate. e.g. running on mLab or Atlas. then you would start your meteor app with a settings file that specified the setting string(s) to connect to the database.

Is there a way I can update my Meteor app without wiping my MongoDB on the production server?

I'm installing my SSL certificate and need to run mupx setup and mupx deploy to get it to work.
However, doing this and then deploying my app will wipe my MongoDB on my production server and users lose all of their accounts. It would be a nightmare.
I simply run mupx deploy after making fixed to my Meteor app to update my app. However, when installing my SSL certificate (according to the Mup documentation) I have to run mupx setup to get it to work.
Is there a way I can do this without wiping my user database on my deployment server?

How do I run Meteor shell in Heroku?

I've deployed my Meteor app to Heroku using the https://github.com/jordansissel/heroku-buildpack-meteor buildpack. My Meteor is v1.0+.
How do I access a server console to my app? Normally on my local dev machine I would run $ meteor shell.
Similarly, how can I meteor reset?
Thanks
If you used the oortcloud meteor buildpack, or a fork of it, the build uses a production mode build of meteor. meteor shell is a development tool and not available for use in production mode.
This is a tradeoff. You could theoretically use use a development mode instance in production but you would have terrible performance. Meteor in development struggles to cope with > 10 users. In production mode the figure is much larger.
meteor reset on the other hand clears the database of the development mode database. To clear up your database log into your database using mongo and drop all the collections. Alternatively run use db.dropDatabase(); (in mongo)

How does Meteor Up work?

I recently created a droplet on Digital Ocean, and then just used Meteor Up to deploy my site to it.
As awesome as it was to not have to mess with all of the details, I'm feeling a little worried and out of the loop about what's happening with my server.
For example, I was using the console management that Digital Ocean provides, and I tried to use the meteor mongo command to investigate what was happening with my database. It just errored, with command not found: meteor.
I know my database works, since records are persistent across accesses, but it seems like Meteor Up accomplished this without retaining any of the testing and development interfaces I grew used to on my own machine.
What does it do??? And how can I get a closer look at things going on behind the scenes?
Meteor Up installs your application to the remote server, but does not install the global meteor command-line utilities.
For those, simply run curl https://install.meteor.com | /bin/sh.
MUP does a few things. Note that this MUP is currently under active development and some of this process will likely change soon. The new version will manage deployment via Docker, add support for meteor build options, and other cool stuff. Notes on the development version (mupx) can be found here: https://github.com/arunoda/meteor-up/tree/mupx.
mup setup installs (depending on your mup.json file) Node, PhantomJS, MongoDB, and stud (for SSL support). It also installs the shell script to setup your environment variables, as well as your upstart configuration file.
mup deploy runs meteor build on your local machine to package your meteor app as a bundled and zipped node app for deployment. It then copies the packaged app to the remote server, unbundles it, installs npm modules, and runs as a node app.
Note that meteor build packages your app in production mode rather than the debug mode that runs by default on localhost when you call meteor or meteor run. The next version of MUP will have a buildOptions property in mup.json that you can use to set the debug and mobileSettings options when you deploy.
Also, since your app is running directly via Node (rather than Meteor), meteor mongo won't work. Instead, you need to ssh into the remote server and call mongo appName.
From there, #SLaks is right about how it sets things up on the server (from https://github.com/arunoda/meteor-up#server-setup-details):
This is how Meteor Up will configure the server for you based on the given appName or using "meteor" as default appName. This information will help you customize the server for your needs.
your app lives at /opt/<appName>/app
mup uses upstart with a config file at /etc/init/<appName>.conf
you can start and stop the app with upstart: start <appName> and stop <appName>
logs are located at: /var/log/upstart/<appName>.log
MongoDB installed and bound to the local interface (cannot access from the outside)
the database is named <appName>

Server side database debugging in Meteor

I am debugging my meteor server as described here: How to debug server side code in a Meteor app
When I try to make a database query I get the following error. How do I investigate the database on the server?
>Meteor.users.find({_id:"HM3JWNm3D2GYMRqZfz"}).fetch()
Error: Can't wait without a fiber
Start your app with:
$ meteor
Open a new Terminal window and type:
$ meteor mongo
This will open the serverside mongo database console.
FYI:
If you deployed your app to meteor you can access its database console via:
$ meteor mongo myapp

Resources