Deployment to multiple servers

CS290F Fall 2006 - UCSB Computer Science - Thorsten von Eicken

Jump to: navigation, search

In order to deploy to multiple servers using capistrano you need to make a bunch of changes to the deploy.rb recipe file. If you don't want to work it out yourself (...) then download config/multi-deploy.rb and either put it in your config directory as-is or overwrite your old deploy.rb with it. If you use a name other than deploy.rb you need to pass the filename to capistrano on each invocation, for example cap -f config/multi-deploy.rb setup.

Setting up your development box

Launch a single instance for testing purposes and get the SSH keys for root. To do this, download the SSH key you used from the AWS console (ec2_ssh_keys link) and stick that in a file called config/my-ssh-key. Then log into the instance and cat /root/.ssh/authorized_keys and stick the last key into config/my-ssh-key.pub. You will only need to do this once on your development box.

Testing on one instance

Now edit the config/multi-deploy.rb to insert your user names and password, and also the host name. The places to edit are clearly marked. Ready? Type cap setup and it should set your server up. If you get a "password:" prompt it's having problems logging into your remote server, so check the keys.

After the setup completes, log into your instance and load the database up. It's already running, all you need to do is restore the data from backup.

With the database set-up, run cap cold_deploy and then point your browser at the instance. You should see your web site!

Deploying to multiple instances

Ok, "but that was just one server" you say. Simply launch a whole bunch of instances and edit the top of config/multi-deploy.rb (tip: if you use the first instance for your DB you don't need to re-restore the contents). Go for another round of cap setup and cap cold_deploy. There you go...

Notes:

  • mysql is started by cap setup and not restarted by any other task, so you need to restart manually if you change the config. (/etc/init.d/mysqld restart)
Personal tools