capistrano - deployment tool
DESCRIPTION
Seminar presentation on Capistrano by Nagesh at Nyros Technologies on 16th June, 2009. http://www.nyros.comTRANSCRIPT
What is Capistrano?
Capistrano is an open source tool for running scripts on
multiple servers;
Intro to Capistrano
• The main functionality of the Capistrano is to Deploy the rails application which you have already written. and we are using the "SVN" subversion to manage the code.
Capistrano will transfer all the files of the rails application which you have developed in your local host to server directly by simply executing an simple command in your command prompt.
Hosting servers?
Installing Capistrano
• Cap –TV => Shows the all available options
• Create a rails application and capistranize your application using the following command
capify .
• It will Creates two files:– config/deploy.rb- capfile
deploy.rb
set :application, “yourappname"set :repository, “your svn url"role :web, “your site address"role :app, " your site address "role :db, " your site address "set :deploy_to, “path to deploy" set :user, “username" set :svn_username, “svn username"set :svn_password, “svn password"
desc "Restart the webserver/fcgi procs, however you do it"task :restart, :roles => :app do # I’m not going to restart anything for this exampleendtask :after_deploy, :roles => :app do
# Set my new dispatch.fcgi to be executablerun "chmod 755 #{deploy_to}/current/public/dispatch.fcgi"
end
• Roles Named subsets of servers
• Multiple applications on your host
Need a Deploy Target?Run once to create the deploy
directories cap setup
it will create the directory structure in server
First Time Deploy?Checks out the latest revision; makes
it the current
cap update_code symlinklighttpd -f /path/to/current/lighttpd.conf
New Release Ready?Updates code on all servers; restarts
FCGI processescap deploy
Deployed a Lemon?Goes back to last revision; restarts
FCGI processes
cap rollback
Need Some Downtime?Disables web access; puts up
maintenance pagecap disable_web
cap enable_web
What’s the Current Revision?
Tasks can access all configuration variables
$ cap current_revision
Chaining Tasks
$ cap status
Multiple Configurations
$ cap -S where=production deploy
Important commands
• 1) cap deploy:setup
This command creates the appropriate directory structure for Capistrano on the deployment server based upon values set in your deploy.rb
2) cap deploy:check
If everything is successful, you should see a message that reads something like…
You appear to have all necessary dependencies installed
• 3) cap deploy:update
push your code out to the server
4) cap deploy:start
to start up your application
Capistrano Just Assumes...
Same deploy directory structure and password on each machine
Web app uses FastCGI with Apache or LightTPD
• As the number of machines and processes in your environment increases... you’re still typing exactly one command.
QUERIES?
With Git?
• default_run_options[:pty] = true
• set :repository, "[email protected]:vanpelt/rails-app.git"
• set :scm, "git"
• set :scm_passphrase, "p@ssw0rd"
• set :user, "deployer"
Thank You