Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Capistrano Deploying Rails Apps with Capistrano By  Chaitanya
What is  Capistrano <ul><li>Capistrano is a utility for managing remote servers and automating remote tasks. It is popular...
<ul><li>It was previously called Switchtower. You can easily rollback to previous versions, do database migrations, and co...
<ul><li>Capistrano will transfer all the files of the rails application which you have developed in your local host to ser...
Deployment isn’t that complex, right? <ul><li>Simple sites are easy </li></ul><ul><ul><li>One Database </li></ul></ul><ul>...
Installing Capistrano <ul><li>Gem install capistrano </li></ul><ul><ul><li>“ cap –h” to see commands </li></ul></ul><ul><l...
Configure Capistrano <ul><li>Edit deploy.rb to match your app’s setup </li></ul><ul><ul><li>You’ll need to specify the ser...
My Modifications to deploy.rb <ul><li>set :application, &quot;captest&quot; </li></ul><ul><li>set :repository, &quot;https...
Setup <ul><li>“ rake remote:exec ACTION=setup” </li></ul><ul><ul><li>Sets up the base directories </li></ul></ul>This crea...
Deployment Structure
Lets Deploy! <ul><li>“Rake --tasks”  to see all our options </li></ul><ul><li>“Rake deploy” to push a version </li></ul><u...
Deploying? <ul><ul><li>cap  deploy </li></ul></ul>
Rollback? <ul><li>cap rollback </li></ul>
Web Access? <ul><li>cap disable_web </li></ul><ul><li>cap enable_web </li></ul>
Various commands <ul><li>cap apache:configure  # Configure Apache. </li></ul><ul><li>cap apache:reload  # Reload Apache </...
Various commands <ul><li>cap deploy:cleanup  # Clean up old releases. </li></ul><ul><li>cap deploy:cold  # Deploys and sta...
<ul><li>Thank You </li></ul>
Upcoming SlideShare
Loading in …5
×

Deploying Rails Apps with Capistrano

3,363 views

Published on

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

http://www.nyros.com

Published in: Technology
  • Be the first to comment

Deploying Rails Apps with Capistrano

  1. 1. Capistrano Deploying Rails Apps with Capistrano By Chaitanya
  2. 2. What is Capistrano <ul><li>Capistrano is a utility for managing remote servers and automating remote tasks. It is popularly used to deploy Rails applications . 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. </li></ul>
  3. 3. <ul><li>It was previously called Switchtower. You can easily rollback to previous versions, do database migrations, and complete other complicated tasks. </li></ul><ul><li>Presently available version is 2.2.0 </li></ul>
  4. 4. <ul><li>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>
  5. 5. Deployment isn’t that complex, right? <ul><li>Simple sites are easy </li></ul><ul><ul><li>One Database </li></ul></ul><ul><ul><li>One Webserver </li></ul></ul><ul><ul><li>One Application </li></ul></ul><ul><li>Multiple Sites? </li></ul>
  6. 6. Installing Capistrano <ul><li>Gem install capistrano </li></ul><ul><ul><li>“ cap –h” to see commands </li></ul></ul><ul><li>Now to apply it to an application </li></ul><ul><ul><li>“ capify .” </li></ul></ul><ul><li>Creates two files: </li></ul><ul><ul><li>config/deploy.rb </li></ul></ul><ul><ul><li>capfile </li></ul></ul>
  7. 7. Configure Capistrano <ul><li>Edit deploy.rb to match your app’s setup </li></ul><ul><ul><li>You’ll need to specify the servers, repository location and deployment path at minimum </li></ul></ul><ul><ul><li>Defaults to SVN, normal SSH port, key in user home, SCM executable on PATH, etc. </li></ul></ul><ul><ul><li>When you first start, you’ll probably only have one server fulfill the DB, web and app roles. </li></ul></ul>
  8. 8. My Modifications to deploy.rb <ul><li>set :application, &quot;captest&quot; </li></ul><ul><li>set :repository, &quot;https://pollack.textdriven.com/svn/captest&quot; </li></ul><ul><li>role :web, &quot;burnaby.textdrive.com&quot; </li></ul><ul><li>role :app, &quot;burnaby.textdrive.com&quot; </li></ul><ul><li>role :db, &quot;burnaby.textdrive.com&quot; </li></ul><ul><li>set :deploy_to, &quot;/users/home/patched/sites/captest&quot; </li></ul><ul><li>set :user, &quot;patched&quot; </li></ul><ul><li>set :svn_username, &quot;captest&quot; </li></ul><ul><li>set :svn_password, &quot;captest&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>
  9. 9. Setup <ul><li>“ rake remote:exec ACTION=setup” </li></ul><ul><ul><li>Sets up the base directories </li></ul></ul>This creates /sites/captest/releases /sites/captest/shared /sites/captest/shared/log /sites/captest/shared/system
  10. 10. Deployment Structure
  11. 11. Lets Deploy! <ul><li>“Rake --tasks” to see all our options </li></ul><ul><li>“Rake deploy” to push a version </li></ul><ul><li>“Rake rollback” to rollback </li></ul>
  12. 12. Deploying? <ul><ul><li>cap deploy </li></ul></ul>
  13. 13. Rollback? <ul><li>cap rollback </li></ul>
  14. 14. Web Access? <ul><li>cap disable_web </li></ul><ul><li>cap enable_web </li></ul>
  15. 15. Various commands <ul><li>cap apache:configure # Configure Apache. </li></ul><ul><li>cap apache:reload # Reload Apache </li></ul><ul><li>cap apache:restart # Restart Apache </li></ul><ul><li>cap apache:start # Start Apache </li></ul><ul><li>cap apache:stop # Stop Apache </li></ul><ul><li>cap app:restart # Restart application server. </li></ul><ul><li>cap app:setup # Setup mongrel </li></ul><ul><li>cap app:start # Start application server. </li></ul><ul><li>cap app:stop # Stop application server. </li></ul><ul><li>cap app:symlinks:setup # Setup application symlinks in the public </li></ul><ul><li>cap app:symlinks:update # Link public directories to shared location. </li></ul><ul><li>cap cache_comm_count # Simple cache of counts for comm users </li></ul><ul><li>cap db:setup # Setup database server. </li></ul><ul><li>cap deploy # Deploys your project. </li></ul><ul><li>cap deploy:check # Test deployment dependencies. </li></ul>
  16. 16. Various commands <ul><li>cap deploy:cleanup # Clean up old releases. </li></ul><ul><li>cap deploy:cold # Deploys and starts a `cold' application. </li></ul><ul><li>cap deploy:migrate # Run the migrate rake task. </li></ul><ul><li>cap deploy:migrations # Deploy and run pending migrations. </li></ul><ul><li>cap deploy:pending # Displays the commits since your last deploy. </li></ul><ul><li>cap deploy:pending:diff # Displays the `diff' since your last deploy. </li></ul><ul><li>cap deploy:restart # Restart the Mongrel processes on the app serv... </li></ul><ul><li>cap deploy:rollback # Rolls back to a previous version and restarts. </li></ul><ul><li>cap deploy:rollback:code # Rolls back to the previously deployed version. </li></ul><ul><li>cap deploy:setup # Prepares one or more servers for deployment. </li></ul><ul><li>cap deploy:start # Start the Mongrel processes on the app server... </li></ul><ul><li>cap deploy:stop # Stop the Mongrel processes on the app server ... </li></ul><ul><li>cap deploy:symlink # Updates the symlink to the most recently depl... </li></ul><ul><li>cap deploy:update # Copies your project and updates the symlink. </li></ul>
  17. 17. <ul><li>Thank You </li></ul>

×