Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Meteor app via Meteor Up or tmux meteor

I'm a bit curious if Meteor Up (or other Meteor app deploying processes like Modulus) do anything fancy compared to copying over your Meteor application, starting a tmux session, and just running meteor to start your application on your server. Thanks ins advance!

like image 748
aspin Avatar asked Oct 21 '15 23:10

aspin


2 Answers

Meteor Up and Modulus seem to just run node.js and Mongodb. They run your app after it has been packaged for production with meteor build. This will probably give your app an edge in performance.

It is possible to just run meteor in a tmux or screen session. I use meteor run --settings settings.json --production to pass settings and also use production mode which minifies the code etc. You can also use a proxy forwarder like Nginx to forward requests to port 80 (http) and 443 (https).

For reference here's my Nginx config:

server {
  listen 80;
  server_name example.com www.example.com;
  return 301 https://example.com$request_uri;
}

server {
  listen 443 ssl;
  server_name www.example.com;

  ssl_certificate /etc/ssl/private/example.com.unified.crt;
  ssl_certificate_key /etc/ssl/private/example.com.ssl.key;

  return 301 https://example.com$request_uri;
}

server {
  listen 443 ssl;
  server_name example.com;

  ssl_certificate /etc/ssl/private/example.com.unified.crt;
  ssl_certificate_key /etc/ssl/private/example.com.ssl.key;



  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

By using this method everything is contained within the meteor container and you have the benefit of meteor watching for changes etc. However, there may be some extra overhead on your server. I'm not sure exactly how much as I haven't tested both ways enough.

The only problem I've found by using this method is it's not easy to get everything automated on reboot, like automatically running tmux then launching meteor, as opposed to using specially designed tools like Node.js Forever or PM2 which automatically start when the server is rebooted. So you have to manually log in to the server and run meteor. If you work out an easy way to do this using tmux or screen let me know.

Edit:

I have managed to get Meteor to start on system boot with the following line in the /etc/rc.local file:

sudo -H -u ubuntu -i /usr/bin/tmux new-session -d '/home/ubuntu/Sites/meteorapp/run_meteorapp.sh'

This command runs the run_meteorapp.sh shell script inside a tmux session once the system has booted. In the run_meteorapp.sh I have:

#!/usr/bin/env bash
(cd /home/ubuntu/Sites/meteorapp && exec meteor run --settings settings.json --production)
like image 188
phocks Avatar answered Oct 16 '22 20:10

phocks


If you look at the Meteor Up Github page: https://github.com/arunoda/meteor-up you can see what it does.

Such as:

Features

Single command server setup Single command deployment Multi server deployment Environmental Variables management Support for settings.json Password or Private Key(pem) based server authentication Access, logs from the terminal (supports log tailing) Support for multiple meteor deployments (experimental)

Server Configuration

Auto-Restart if the app crashed (using forever) Auto-Start after the server reboot (using upstart) Stepdown User Privileges Revert to the previous version, if the deployment failed Secured MongoDB Installation (Optional) Pre-Installed PhantomJS (Optional)

So yes... it does a lot more...

like image 5
Eliezer Steinbock Avatar answered Oct 16 '22 20:10

Eliezer Steinbock