Capistrano Deployment tool By  Nagesh
What is Capistrano? <ul><li>Capistrano is an  open source  tool for running scripts on multiple servers;  </li></ul>
Intro to Capistrano <ul><li>The main functionality of the Capistrano is to Deploy the rails application which you have alr...
Hosting servers?
How Do I Install It? gem install capistrano
Installing Capistrano <ul><li>Cap –TV  => Shows the all available options  </li></ul><ul><li>Create a rails application an...
 
deploy.rb <ul><li>set :application, “yourappname&quot; </li></ul><ul><li>set :repository, “your svn url&quot; </li></ul><u...
<ul><li>Roles  Named subsets of servers </li></ul>
<ul><li>Multiple applications on your host </li></ul>
Need a Deploy Target? Run once to create the deploy directories <ul><li>cap setup </li></ul><ul><li>it will create the dir...
First Time Deploy? Checks out the latest revision; makes it the current <ul><li>cap update_code symlink </li></ul><ul><li>...
New Release Ready? Updates code on all servers; restarts FCGI processes <ul><ul><li>cap  deploy </li></ul></ul>
Deployed a Lemon? Goes back to last revision; restarts FCGI processes <ul><li>cap rollback </li></ul>
Need Some Downtime? Disables web access; puts up maintenance page <ul><li>cap disable_web </li></ul><ul><li>cap enable_web...
What’s the Current Revision? Tasks can access all configuration variables $ cap current_revision
Chaining Tasks <ul><li>$ cap status </li></ul>
Multiple Configurations <ul><li>$ cap -S where=production deploy </li></ul>
Important commands <ul><li>1) cap deploy:setup  This command creates the appropriate directory structure for Capistrano on...
Capistrano Just Assumes... <ul><li>Same deploy directory structure and password on each machine </li></ul><ul><li>Web app ...
<ul><li>QUERIES? </li></ul>
With Git? <ul><li>default_run_options[:pty] = true  </li></ul><ul><li>set :repository, &quot;git@github.com:vanpelt/rails-...
<ul><li>Thank You </li></ul>
Upcoming SlideShare
Loading in …5
×

Capistrano - Deployment Tool

4,004 views

Published on

Seminar presentation on Capistrano by Nagesh at Nyros Technologies on 16th June, 2009.

http://www.nyros.com

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,004
On SlideShare
0
From Embeds
0
Number of Embeds
216
Actions
Shares
0
Downloads
64
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Capistrano - Deployment Tool

    1. 1. Capistrano Deployment tool By Nagesh
    2. 2. What is Capistrano? <ul><li>Capistrano is an open source tool for running scripts on multiple servers; </li></ul>
    3. 3. Intro to Capistrano <ul><li>The main functionality of the Capistrano is to Deploy the rails application which you have already written. and we are using the &quot;SVN&quot; 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. </li></ul>
    4. 4. Hosting servers?
    5. 5. How Do I Install It? gem install capistrano
    6. 6. Installing Capistrano <ul><li>Cap –TV => Shows the all available options </li></ul><ul><li>Create a rails application and capistranize your application using the following command </li></ul><ul><ul><li>capify . </li></ul></ul><ul><li>It will Creates two files: </li></ul><ul><ul><li>config/deploy.rb </li></ul></ul><ul><ul><li>- capfile </li></ul></ul>
    7. 8. deploy.rb <ul><li>set :application, “yourappname&quot; </li></ul><ul><li>set :repository, “your svn url&quot; </li></ul><ul><li>role :web, “your site address&quot; </li></ul><ul><li>role :app, &quot; your site address &quot; </li></ul><ul><li>role :db, &quot; your site address &quot; </li></ul><ul><li>set :deploy_to, “path to deploy&quot; </li></ul><ul><li>set :user, “username&quot; </li></ul><ul><li>set :svn_username, “svn username&quot; </li></ul><ul><li>set :svn_password, “svn password&quot; </li></ul><ul><li>desc &quot;Restart the webserver/fcgi procs, however you do it&quot; </li></ul><ul><li>task :restart, :roles => :app do </li></ul><ul><li># I’m not going to restart anything for this example </li></ul><ul><li>end </li></ul><ul><li>task :after_deploy, :roles => :app do </li></ul><ul><li># Set my new dispatch.fcgi to be executable </li></ul><ul><li>run &quot;chmod 755 #{deploy_to}/current/public/dispatch.fcgi&quot; </li></ul><ul><li>end </li></ul>
    8. 9. <ul><li>Roles Named subsets of servers </li></ul>
    9. 10. <ul><li>Multiple applications on your host </li></ul>
    10. 11. Need a Deploy Target? Run once to create the deploy directories <ul><li>cap setup </li></ul><ul><li>it will create the directory structure in server </li></ul>
    11. 12. First Time Deploy? Checks out the latest revision; makes it the current <ul><li>cap update_code symlink </li></ul><ul><li>lighttpd -f /path/to/current/lighttpd.conf </li></ul>
    12. 13. New Release Ready? Updates code on all servers; restarts FCGI processes <ul><ul><li>cap deploy </li></ul></ul>
    13. 14. Deployed a Lemon? Goes back to last revision; restarts FCGI processes <ul><li>cap rollback </li></ul>
    14. 15. Need Some Downtime? Disables web access; puts up maintenance page <ul><li>cap disable_web </li></ul><ul><li>cap enable_web </li></ul>
    15. 16. What’s the Current Revision? Tasks can access all configuration variables $ cap current_revision
    16. 17. Chaining Tasks <ul><li>$ cap status </li></ul>
    17. 18. Multiple Configurations <ul><li>$ cap -S where=production deploy </li></ul>
    18. 19. Important commands <ul><li>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 </li></ul><ul><li>3) cap deploy:update push your code out to the server 4) cap deploy:start to start up your application </li></ul>
    19. 20. Capistrano Just Assumes... <ul><li>Same deploy directory structure and password on each machine </li></ul><ul><li>Web app uses FastCGI with Apache or LightTPD </li></ul><ul><li>As the number of machines and processes in your environment increases... you’re still typing exactly one command. </li></ul>
    20. 21. <ul><li>QUERIES? </li></ul>
    21. 22. With Git? <ul><li>default_run_options[:pty] = true </li></ul><ul><li>set :repository, &quot;git@github.com:vanpelt/rails-app.git&quot; </li></ul><ul><li>set :scm, &quot;git&quot; </li></ul><ul><li>set :scm_passphrase, &quot;p@ssw0rd&quot; </li></ul><ul><li>set :user, &quot;deployer&quot; </li></ul>
    22. 23. <ul><li>Thank You </li></ul>

    ×