Skip to content

HOME canary releases

emmagcta edited this page Feb 28, 2019 · 1 revision

Setup canary app version on the server

Local setup

We need to create a new config for mup, which will deploy another app, which will be connected to the same database but running on different port.

  1. Create new MUP deploy config by copying the directory .deploy/home to .deploy/home-canary

  2. Change .deploy/home-canary/mup.js as following (change bolded lines):

module.exports = {
 plugins: ['mup-git'],
 servers: {
   one: {
     host: 'mosbehome.ctagroup.org',
     username: 'ubuntu',
     pem: '/home/pgorecki/.ssh/home-cta.pem',
   },
 },

 meteor: {
   name: 'home-monterey-canary',
   path: '../../',
   docker: {
     image: 'abernix/meteord:node-8.9.1-base',
     args: [
       '--link=mongodb:mongodb'
     ],
   },
   servers: {
     one: {},
   },
   buildOptions: {
     serverOnly: true,
   },
   env: {
     PORT: '4000',
     ROOT_URL: 'https://mosbehome.ctagroup.org',
     MONGO_URL: 'mongodb://mongodb:27017/home-monterey',
   },
   deployCheckWaitTime: 60,
 },
};
  1. Double check that you are in .deploy/home-canary directory.
  2. Run mup setup && mup deploy from canary directory. New docker container with an app will be running on port 4000, which is connected to the same Mongodb as the production app running on port 3000 (both apps use the same DB)

Nginx setup

We need to configure Nginx server, which will redirect user either to a production app or canary app based on the cookie value. Nginx

  1. Login to production server using mup ssh one from .deploy/home-canary directory.
  2. Edit /etc/nginx/sites-enabled/home.ctagroup.org as following:
map $cookie_canary $server {
  default meteor;
  "yes"  meteor_canary;
}

upstream meteor {
  server 127.0.0.1:3000;
}

upstream meteor_canary {
  server 127.0.0.1:4000;
}

server {
  server_name home.ctagroup.org   www.home.ctagroup.org;

  access_log /var/log/nginx/home.ctagroup.org.access.log ;
  error_log /var/log/nginx/home.ctagroup.org.error.log;

  root /var/www/home.ctagroup.org/htdocs;

  index  index.html index.htm;

  location ~ /\.well-known/ {
	try_files $uri $uri/ =404;
  }

  location / {
	proxy_pass http://$server;
     add_header X-debug            	$server;
	proxy_http_version 1.1;
	proxy_set_header Upgrade      	$http_upgrade;
	proxy_set_header Connection   	'upgrade';
	proxy_set_header X-Forwarded-For  $remote_addr;
	proxy_set_header X-Real-IP    	$remote_addr;
	proxy_set_header X-Client-Verify  SUCCESS;
	proxy_set_header X-Client-DN  	$ssl_client_s_dn;
	proxy_set_header X-SSL-Subject	$ssl_client_s_dn;
	proxy_set_header X-SSL-Issuer 	$ssl_client_i_dn;
	proxy_read_timeout            	1800;
	proxy_connect_timeout         	1800;
 }
    
  # include common/locations.conf;
  include /var/www/home.ctagroup.org/conf/nginx/*.conf;
}
  1. Restart nginx sudo service nginx restart

Enable canary release

User visiting https://home.ctagroup.org/ can switch to canary server by opening web console (F12) and typing the following in the console: document.cookie='canary=yes'. Then hit F5 to refresh the page. You will see the app version on the front page of HOME app. Also, for apps deployed after 2018.04.27 you can check the build info using:re

Meteor.call('app.buildInfo', function (err, res) { console.log(err,res) }) 

in the browser console.

Disable canary release

To switch back to the production server, visit https://home.ctagroup.org/, open web console (F12) and type typing the following in the console: document.cookie='canary=no'. Then hit F5 to refresh the page.

Clone this wiki locally