capistrano - deployment tool

23
Capistrano Deployment tool By Nagesh

Upload: nyros-technologies

Post on 17-May-2015

3.403 views

Category:

Technology


7 download

DESCRIPTION

Seminar presentation on Capistrano by Nagesh at Nyros Technologies on 16th June, 2009. http://www.nyros.com

TRANSCRIPT

Page 1: Capistrano - Deployment Tool

Capistrano

Deployment tool

By Nagesh

Page 2: Capistrano - Deployment Tool

What is Capistrano?

Capistrano is an open source tool for running scripts on

multiple servers;

Page 3: Capistrano - Deployment Tool

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.

Page 4: Capistrano - Deployment Tool

Hosting servers?

Page 5: Capistrano - Deployment Tool

How Do I Install It?

gem install capistrano

Page 6: Capistrano - Deployment Tool

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

Page 8: Capistrano - Deployment Tool

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

Page 9: Capistrano - Deployment Tool

• Roles Named subsets of servers

Page 10: Capistrano - Deployment Tool

• Multiple applications on your host

Page 11: Capistrano - Deployment Tool

Need a Deploy Target?Run once to create the deploy

directories cap setup

it will create the directory structure in server

Page 12: Capistrano - Deployment Tool

First Time Deploy?Checks out the latest revision; makes

it the current

cap update_code symlinklighttpd -f /path/to/current/lighttpd.conf

Page 13: Capistrano - Deployment Tool

New Release Ready?Updates code on all servers; restarts

FCGI processescap deploy

Page 14: Capistrano - Deployment Tool

Deployed a Lemon?Goes back to last revision; restarts

FCGI processes

cap rollback

Page 15: Capistrano - Deployment Tool

Need Some Downtime?Disables web access; puts up

maintenance pagecap disable_web

cap enable_web

Page 16: Capistrano - Deployment Tool

What’s the Current Revision?

Tasks can access all configuration variables

$ cap current_revision

Page 17: Capistrano - Deployment Tool

Chaining Tasks

$ cap status

Page 18: Capistrano - Deployment Tool

Multiple Configurations

$ cap -S where=production deploy

Page 19: Capistrano - Deployment Tool

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

Page 20: Capistrano - Deployment Tool

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.

Page 21: Capistrano - Deployment Tool

QUERIES?

Page 22: Capistrano - Deployment Tool

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"

Page 23: Capistrano - Deployment Tool

Thank You