How to setup a Linux web server using the command line, Part 5 : Capistrano Deployment

#
# Capistrano setup for Subversion+Capistrano Web Applications
#

Honestly, our days are done with uploading program changes one file at a time, so let’s automate the whole svn commit and application deployment process with an easy-to-use ruby gem called Capistrano.  After we “capify” our application, we’ll be able to deploy our application to the remote server with a simple “cap deploy” command.  Capistrano will also take care of the svn commit process for the new application release/revision.  We’ll still use Subversion for our day-to-day revision commitals, as we do in Part 4, but it’s nice that Capistrano handles a new svn commit upon deployment.

# on local machine

# navigate to your working copy

cd ~/work/myproject1

# capify working copy

capify .

# edit generated config/deploy.rb file

nano config/deploy.rb
see cap_config_deploy_local.txt file

# capistrano needs to write some files to the server

cap deploy:setup

# commit capification to svn

svn status
svn add Capfile
svn add config/deploy.rb
svn commit -m “capified with capistrano”

# rails users: setup a script/spin file
# so capistrano may restart mongrels and mongrel clusters

touch script/spin
nano script/spin
# add one line:
——-
/home/super/public_html/mydomain1.com/current/script/process/spawner -p 8000 -i 2 -e production
——-

# add script/spin file and commit to svn

svn add script/spin
svn commit -m “added capistrano’s script/spin mongrel restart file”

# propset script/spin file and commit to svn

svn propset svn:executable on script/spin
svn commit -m “propset script/spin file as executable for subversion”

# run some tests to make sure capistrano can deploy

cap deploy:migrate
cap deploy:cold

# deploy your application for real!

cap deploy

# make changes in some file content

cd ~/work/corext_work

# when done

svn add –force .
svn commit -m “import some new changes”
cap deploy

Done!

Now on to Part 6 where we configure and start our mongrel clusters for our Ruby on Rails Web 2.0 applications…

Leave a Comment

You must be logged in to post a comment.