A couple of capistrano 2 recipes libraries
Posted by Giovanni Intini | Filed under Capistrano, Nimboo, Programming, Rails, Ruby, Ruby on Rails
I kept playing with Capistrano 2 after my last article, and I’ve refactored quite a bit my recipes, finally moving them in their own subversion repository. This allows much quicker deployment with my new rails applications. Here’s how I do it:
$ rails my_new_application $ cd my_new_application $ capify .
Then I edit Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator load 'lib/recipes/site5' # This is my site5 recipe load 'lib/recipes/medlar' # The general use recipes load 'config/deploy'
The site5 and medlar namespaces hold default configuration values, define some callbacks and the following tasks:
cap deploy:medlar:rails:freezer:edge # Fetch Rails edge and puts it into sh... cap deploy:medlar:rails:freezer:stable # Fetch Rails stable and puts it into ... cap deploy:medlar:rails:link # Links Rails to application/vendor cap deploy:medlar:rails:update # Updates the fetched version of rails.cap deploy:site5:kill_dispatch_fcgi # Kills Ruby instances on Site5
cap deploy:site5:link_public_html # Links public_html to current_path/pu...
Last but not least, here’s the simple, clean and elegant deploy.rb:
set :application, "my_new_application" set :user, "the_username" set :repository, "repo_address" set :deploy_to, "/home/#{user}/apps/#{application}" role :app, "server.com" role :web, "server.com" role :db, "server.com", :primary => true
Quite readable, isn’t it?
The recipes are available via anonymous subversion: https://svn1.hosted-projects.com/medlar/recipes/
Enjoy and let me know if you found them useful.
October 9th, 2007 at 3:32 pm
[...] This is a followup to A Couple of Capistrano 2 Recipes Libraries [...]
July 11th, 2008 at 5:24 pm
It may also be beneficial to your audience if you showed what the included recipe files for site5 and medlar look like. Obviously any sensitive passwords can be removed to protect the innocent!
July 12th, 2008 at 1:42 pm
@filmprog: they’re actually in the repository, so you can check them out