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

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?

Related

Deploy asp.net react template without nodejs dependency on IIS server

I'm having problems with deploying and running the ReactRedux template on an IIS server which doesn't has nodejs. The app was created using AspNetCore.SpaTemplates' "reactredux" option:
https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
The app is the same as the template, no changes were made. We first tried to host it on IIS with nodejs installed on the IIS server, everything works fine:
screenshot with nodejs
But when we uninstalled nodejs from the server and restarted IIS, it wasn't working anymore:
screenshot without nodejs
We couldn't figure out what the error is because running it in development mode requires nodejs and when we run it with dotnet run in development mode the error message complains about node.js not being installed, as expected.
We tried to deploy the app running:
$Env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet publish -c Release
and using Visual Studios build>publish interface.
Acording to the docs here, the app shouldn't need nodejs when its deployed for production:
https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio
Unlike the development build, the production build doesn't require
Node.js to be installed on the server.
I'm new to asp.net and deploying apps on IIS, maybe the solution is trivial but we couldn't manage to solve this, thanks in advance.
If you don't want any nodejs dependency, make sure you disabled server-side prerendering:
https://github.com/aspnet/JavaScriptServices/issues/932
If you're not doing server-side prerendering, then you will not need
Node.js on your production server, because all the JS will be executed
on the client side.
If you are doing server-side prerendering (which is the default in the
React-Redux template in this repo), then you do need Node.js on your
production server, because the prerendering process involves executing
your JavaScript code on the server.
To disable server-side prerendering do the following:
Remove asp-prerender-module="ClientApp/dist/main-server" from Views>Home>Index.cshtml
Remove #addtaghelper "*, Microsoft.AspNetCore.SpaServices" from Views/_ViewImports.cshtml

How to view Meteor server errors on production server

Is there a way to access the Meteor server logs on a production server? All I needs is something that records what I'd see as the server console output on my dev machine, in a log file on the server. I would have expected Meteor to log them somewhere by default but I can't find anything.
I'm running Meteor 1.6 on a Digital Ocean droplet, Ubuntu 16.04.3. Deployed with Phusion Passenger.
I've hunted around and there are a bunch of logging packages for Meteor but I can't figure how to use any of them; there don't seem to be any basic examples or instructions.
This must be a really common requirement - anybody know how to do this? Thanks!
Remember that Meteor runs on Node.js. Therefore, many things valid for Node.js is also valid for Meteor like location of the default root folder of the built-in web server. You should check the path "/var/www/html", first for the server logs.

Trying to run meteor up mup setup

It appears mup setup can't run without a mup.json file. But, it appears the mup.json file is primarily used for mup deploy. Reason I ask is I'm trying to execute mup setup on the host server and it fails without the server credentials but considering that I'm already logged onto the server executing the setup I don't understand why the mup.json is being required in the first place? I'm not deploying an application so none of the application-specific settings would apply, right? If I don't have a mup.json on the server then mup setup throws an error that the mup.json file does not exist. It didn't seem really clear on the meteor up web site. Thanks!
You should run Meteor Up from your local machine as that's what it's designed for. I wrote about how to deploy with meteor up a while back and that should help you.
In a nutshell I believe you're thinking about this the wrong way. With mup, meteor deploy and soon galaxy deploy, you no longer need to "upload" your files and then go and manage them from the server. Instead your files stay local, you deploy (which will upload them) and deployment sets up your server and file structure.
Misunderstanding on my part. mup setup is something you run on your remote machine, not the host machine.

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>

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

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)

Resources