Deploying and importing production data with capistrano

From Expertiza_Wiki
Revision as of 19:57, 17 May 2016 by Rkyadav (talk | contribs) (Created page with "We use Capistrano to work with the production Expertiza server. Capistrano is used both for deploying the application and loading production data. Capistrano is only available on...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

We use Capistrano to work with the production Expertiza server. Capistrano is used both for deploying the application and loading production data. Capistrano is only available on Mac OSX and Linux.

Initial Capistrano Setup

Install the capistrano gem

gem install capistrano

Capistrano uses SSH keys to authenticate with the production server (expertiza.ncsu.edu). If you do not already have an SSH key, you can generate one with ssh-keygen on OSX and Linux. It will prompt you for where to save the key (press enter to accept the default) and generate two files: id_rsa and id_rsa.pub.

Send your public key (~/.ssh/id_rsa.pub) to someone who has admin access on expertiza.ncsu.edu. They should append the contents of your public key to /home/rails/.ssh/authorized_keys.

Using Capistrano

All capistrano commands are run from your development machine. You do not need to SSH into expertiza.ncsu.edu. Capistrano does this for you in the background.

View all capistrano tasks using the command:

cap -T

Deploying with Capistrano

If the updates you are deploying do not include any migrations

cap deploy

If the deploy contains migrations:

cap deploy:migrations

deploy:migrations is the equivalent of running

cap deploy
cap deploy:migrate

Loading production database onto a development machine

You can use the cap load_production_data task to clone the production server's database into your local database.

Running this task downloads a database dump from the production server and loads it into your local development database. It uses the database settings in config/database.yml. This means that your config/database.yml production environment must be set to use the pg_development database, since that's the database the production server is running on. Note that this will drop and recreate your local development database.

To load production data:

cap load_production_data