Finally capistrano deployment

Posted on Thu Jun 21 @ 16:00:13

Today I managed to get capistrano deployment finished. I’ve never used capistrano before and it took me a few hours to set it up but at the end I managed it. :)

I’m using bzr as my VCS and mongrel_cluster behind nginx as web server so I had to customize the config/deploy.rb script. Also I’m using capistrano 2.0. Here is my config/deploy.rb:


    set :application, "munitic.com.hr" 
    set :repository,  "/opt/repo_mirror/#{application}" 
    set :deploy_to, "/var/www/apps/#{application}" 
    set :scm, :bzr
    set :checkout, "branch" 

    role :app, "www.munitic.com.hr" 
    role :web, "www.munitic.com.hr" 
    role :db,  "www.munitic.com.hr", :primary => true

    namespace :deploy do
      desc "Restart mongrel cluster" 
      task :restart, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::restart
        CMD
      end

      task :start, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::start
        CMD
      end

      task :stop, :roles => :app do
        run <<-CMD
          cd #{current_path} &&
          mongrel_rails cluster::stop
        CMD
      end
      task :before_update_code do
        `bzr push sftp://munitic.com.hr/opt/repo_mirror/#{application}`
      end

      task :after_update, :roles => :app do
        run "ln -s /var/www/apps/#{application}/shared/photos 
              #{current_path}/public/photos" 
      end
    end

I’ve used tips from here. I hope this helps someone!

Posted in Rails, 0 Comments Comments