Newbie to meteor


#1

Hi, I have just completed simple todo app with meteor 1.5 and I was looking for deployment options. What would you recommend is the easiest deployment path excluding galaxy. Is Mupx still working?? Heroku, AWS, digital Ocean


#2

Easiest is a bit subjective, but I recently did my first deployment and used Digital Ocean with a Ubuntu 16.04 server, and then just used the meteor build and forever to keep it running.

I’m adding my instructions from that project below. I use a private GitLab, but I think you may be able to get there on that project.

I intend to move it to github in the near future, but regardless the instructions below should apply.

Once you are ready, you need to do a few things. I’m going to assume you’re using Linux (Debian based), if not, just modify commands to your architecture.

Install Meteor https://www.meteor.com/install

Install MongoDB and start it as a daemon. The default port is 27017, but you can read their documentation to change it if you want.
When you run the git clone command up next, it will create the app directory, and pull in all files from the git repo.

git clone http://gitlab.forceterminate.com/bmcgonag/trivia-challenge.git

cd into the newly created / cloned directory

cd trivia-challenge

run the meteor command for the first time.

meteor

If all was successful, no reason it wouldn’t be, there may be a few cleanup items to deal with.

  • 6a. sometimes meteor wants you to get a better bcrypt module. The command is generally provided in the text as meteor starts. You may have to scroll a little to see it.
  • 6b. also, you may want to run meteor npm install, and allow the npm modules to be installed. The meteor command alone may do this though.

Once meteor is running, you can check the app by going to your IP address or URL at port 3000 to make sure the site loads.

For example, if your site is my-trivia.com, you’d go to http://my-trivia.com:3000 in your browser to make sure it all loads up.

NOTE: Don’t start putting in a ton of data, as this is the development environment only. You don’t want to use this as your production environment.

Setting up the app for production.

If you want to run this in a more stable environment, you’ll need to do a few more steps.

Install FOREVER from npm.

npm i -g forever

NOTE: you need to run the -g option with root privileges.

Forever is an application that will watch your app and make sure it comes back up should it crash for some reason.

We need to build the meteor app to run for production. It’s not hard, just takes some time.

from the app directory created when you cloned the git repo, run the following command. Notice that I’m telling the app to build in a different directory than the one I’m in.

meteor build --directory ../trivia-challenge-node

This ‘compiles’ the app and minifies all the css and js as well as makes the actual nodejs capable version.

When it’s done, move back one directory, and into the newly created build directory.

cd ../trivia-challenge-node

Now, do an ls and notice the bundle directory.

cd into bundle.

Now we need to install dependencies.
cd programs/server

npm install

This will install all npm dependencies for the production system.

Now we need to set some environmental variables for our app to use when running.

First let’s set the MONGO_URL (tell the app where to connect to our Mongo DB).

export MONGO_URL="mongodb://127.0.0.1:27017/trivia-challenge"

This command tells the system to find mongodb on our local server, and to use port 27017 (however, if you told mongo to run on a different port, then please change that number to match the port number you selected), and to use a database called “trivia-challenge”.

Now we’ll telll our app what it’s main URL is (basically what a user will type into their browser to get to our web bbased application).

export ROOT_URL="http://<your web site name or IP>"

Now, we tell our app that it should run on a port. If you want someone one to just type the name of your site and get straight to your app, then use port 80. Any other port (besides 443) will need the user to enter the port after your web site name like this http://:port

export PORT=80

Now try the site.

We can run a very simple test to make sure we’ve set everything up properly.

Run the command:

node main.js

from the bundle directory in our production app main directory.

Give it about 10 seconds, then if you don’t get any errors in the terminal, go to your web site or IP. Don’t forget, that if you didn’t specify a port, use port 3000, and if you specified a port other than 80, enter that port after your site name and a colon.

The site should come up to a login / welcome page.

If it does AWESOME!

If not, it’s time for trouble shooting.

Now, we want our site to continue running. The issue with the node command, is that when we close our terminal, it will kill our node command.

For this we use a tool called “forever”.

So, first, in the terminal do the key combo CTRL+C, this will tell our node app to stop for a minute.

Next we want to start the app again using “forever”.

It’s easy.

forever start -l forever.log -o output.log -e error.log main.js

What this says is start our main.js with the forever command. Output anything that forever would put out to the terminal window into a file called forever.log, and any normal output from our app to output.log, and any errors that happen to a file called error.log.

In my setup the file forever.log is located in /home/.forever

When you hit enter, it should start. Now you can close the terminal window and still get to your web application.


#3

Wow Thats very helpful!!!


#4

Please share any painpoints during your trial of deployment. I would like to tweak my articles about this subject on my blog to make it easier for new people.


#5

I just want to chip in that the most recent “official” mup branch works flawlessly in combination with AWS.

To make this happen, all you have to do is setup an Ubuntu AMI instance, configure its ports 80 (and maybe 443 for SSL) to be open and download the access certificates.

The rest of the configuration is done by adapting the mup.js file to reflect your server, MongoDB setup and access certificates. You can either run MongoDB on the same server (in this case you would be responsible for backups) or use an external server like Compose (as I am doing it).

After the configuration via mup.js, you type in mup setup and mup deploy and the rest just works automatically. Once you know what to do, setting up a new instance is a matter of just 5 minutes or so. Awesome. mup can even setup an SSL certificate automatically and let it sign by letsencrypt.

I guess that the same applies to a server hosted on DigitalOcean, so I would definitely give mup a try even if you decide against AWS.

Another nice thing about mup is that it supports a multi-server setup, so you can differentiate between staging and production or maintain several clustered servers. I am using a staging setup and deploying a new version of my app to either instance is just a matter of one command at the terminal prompt.

Side note: When Kadira was still in charge of mup, it was a bit of a mess, since there were several mup versions and it was quite hard to get which one was the right one. But since zodern took over, the package is very well maintained. My kudos to him and the whole mup team.


#6

Is there any latest detailed guide for meteor 1.5 or youtube video for deploying it on AWS , I was able to deploy to heroku with the horse buildpack and it was smooth. Now looking forward to AWS.


#7

Would love to demonstrate it! Do you need it urgently? If not you will have a video on youtube in 1 week or less


#8

@cloudspider Cool, that’s sounds great! Was thinking about writing a blog post, too. But having a YouTube video from you would be even more awesome. You’re definitely more experienced in DevOps than me. :slight_smile:


#9

Oh thats great to hear .No its not urgent , just learning now , so that by the end of the year I can deploy my portfolio.


#10

Thats awesome , do link your post here. I am new to Meteor and community is pure awesomeness !! Thanks for support guys


#11

I’ve only used Heroku, so I don’t have anything to compare to, but Heroku was dead simple and works flawlessly. To deploy you just type git push heroku, couldn’t be simpler.


#12

I’ve deployed Meteor on Linode, DigitalOcean, and Vultr using the new mup that was taken over by zodern from kadira, and I can say that it works great everytime, and simple process, too!. let’s encrypt SSL auto renew also works great.