Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Migrate an Application

Mark Orr edited this page Jul 22, 2014 · 22 revisions

The easiest way to upgrade the operating system is to create a new server with the latest Linux distribution of our choice and then move the ICU applications and databases there. We've covered setting up a new server elsewhere. Here we describe moving applications between servers.

Moving www2.icu.ie

At the time of this move, late 2013, the new Rails version of the main ICU site was still in development and using the hostname www2. The move was from ratalacha to aontas.

  • ratalacha: Centos 5.9, Ruby 1.9.3
  • aontas: Centos 6.4, Ruby 2.0.0

The setup of aontas already included:

  • an empty www_production MySQL database with the correct user account already setup
  • an empty (apart from the shared/log directory) /var/apps/www
  • an Apache log directory exclusively for this application (/var/log/httpd/www)

Shutting down the old app

Preliminary to moving the application, it was sent into maintenance mode on ratalacha by running the following Capistrano (version 2) command on abidjan (Mark's desktop development machine at the time):

$ bin/cap deploy:web:disable

Then the DNS record for www2.icu.ie was changed to point at aontas instead of ratalacha. While waiting for the DNS change to take effect (about a day), the following data was copied from ratalacha to aontas:

  • the contents of the production database (www_production)
  • the relevant section of /etc/httpd/conf.d/vhost.conf (which required one adjustment - the IP address)

The following upgrades and tests were performed:

  • two gems (therubyracer and libv8) were updated (enabled by the move from Centos 5 to 6)
  • the test suite was run with the new Ruby (2.0.0) in the development environment (abidjan)

Preparing for the first deploy

At this stage all we have in /var/apps/www on aontas:

$ tree /var/apps/www
/var/apps/www
└── shared
    └── log

If you recall, when we configured logrotate during the setup of aontas, we created these directories.

Capistrano will set up the other shared directories and links for us, but we need to supply the two files of secrets that ICU apps use (neither of which is in the git repository), so we copy them from ratalacha:

$ cd /var/apps/www/shared
$ mkdir config
$ cd config
$ scp ratalacha.icu.ie:/var/apps/www/shared/config/databases.yml .
$ scp ratalacha.icu.ie:/var/apps/www/shared/config/app_config.yml .

In general one might want to modify such files, but in this case, no changes were required.

So now we have:

$ tree /var/apps/www
└── shared
    ├── config
    │   ├── app_config.yml
    │   └── database.yml
    └── log

Deploy with Capistrano

At this stage the following Capistrano (version 3) command run from a development machine (such as abidjan) will deploy and start the application:

$ bin/cap production deploy

After this, the contents of /var/apps/www will have greatly expanded. At the top level should be something like this:

$ tree -L 1 /var/apps/www
/var/apps/www
├── current -> /var/apps/www/releases/20131122173513
├── releases
├── repo
├── revisions.log
└── shared

Moving ratings2.icu.ie

In July 2014 ratings.icu.ie was still running on ratalacha when it was decided to move it to aontas. The first goal would be to get the application working as ratings2.icu.ie. When that was ready the ratalacha app would be turned off and this new one renamed to ratings.icu.ie.

As for the move of www2.icu.ie (see above) certain things were already in place after the initial server setup:

  • an empty ratings_production MySQL database with the user accounts already setup
  • an empty (apart from the shared/log directory) /var/apps/ratings
  • an Apache log directory exclusively for this application (/var/log/httpd/ratings)
  • rotation for both rails and apache logs (/etc/logrotate.d/ratings)

Configuring Apache

The relevant section from /etc/httpd/conf.d/vhost.conf on ratalacha was inserted into the same file on aontas with one change: for now, this vitual host will go under the name ratings2.icu.ie.

Preparing for the first deploy

To begin with, all we have in /var/apps/ratings on aontas:

$ tree /var/apps/ratings
/var/apps/ratings
└── shared
    └── log

When we configured logrotate during the setup of aontas, we created these directories.

Capistrano will set up the other shared directories and links for us, but we need to supply the two files of secrets that the ratings app uses (neither of which is in the git repository), so we copy them from ratalacha:

$ cd /var/apps/ratings/shared
$ mkdir config
$ cd config
$ scp ratalacha.icu.ie:/var/apps/ratings/shared/config/databases.yml .
$ scp ratalacha.icu.ie:/var/apps/ratings/shared/config/app_config.yml .

The old ratalacha app (Rails 4.0.1) is going to be replaced with one using a slightly more modern Rails (4.1.4) and which is using the secrets.yml technique for storing secrets. So we need to edit the app_config.yml file appropriately and change it's name, ending up with:

$ tree /var/apps/ratings
└── shared
    ├── config
    │   ├── app_config.yml
    │   └── secrets.yml
    └── log