Piku’s Blog

February 29, 2008

Playing with capistrano and git

Filed under: Programming, Ruby on Rails — Tags: , , , , — Mihai @ 8:50 pm

Today I wanted to see how easy it is to use capistrano to deploy apps.

Because I’m using git it was a bit harder but not impossible, I am using the latest capistrano version (2.2.0). It’s not very hard and I like to edit something locally, git commit, git push then cap deploy and the new version is on the server immediately.

My config/deploy.rb file:

set :application, "myapp"
set :repository,  "ssh://myserver/git/app.git"
set :deploy_to, "/home/mihai/apps/#{application}"
set :scm, "git"
ssh_options[:paranoid] = false
set :domain, "myserver.net"
role :app, domain
role :web, domain
role :db, domain, :primary => true
default_run_options[:pty] = true
set :user, "mihai"
set :runner, "mihai"
set :use_sudo, false
set :deploy_via, :remote_cache
set :mongrel_port, "3001"

And my config/mongrel.rb (loaded from Capfile) that is just a plain mongrel controller (no clustering):

namespace :deploy do
 task :start, :roles => :app do
  run "cd #{current_path} && mongrel_rails start -e production -p #{mongrel_port} -d"
 task :restart, :roles => :app do
   run "cd #{current_path} && mongrel_rails restart"
 task :stop, :roles => :app do
   run "cd #{current_path} && mongrel_rails stop"

If you are interested I can post a full tutorial including setting up apache and git on the server.

Create a free website or blog at WordPress.com.