Trying out Vlad the Deployer 26 Jan 2008
This blog wasn’t using any form of automated deployment until late last night. For the longest time rsync and ssh seemed to be adequate enough even though I’m familiar with “Capistrano”:http://www.capify.org and had been well aware of “Vlad the Deployer’s”:http://rubyhitsquad.com/Vlad_the_Deployer.html release. Since I know about Capistrano I decided to invest some time getting to know Vlad.

This site is currently running on a 0.7.3 “Mephisto”:http://mephistoblog.com/ installation with a custom theme by yours truly and it’s hosted on “Dreamhost”:http://www.dreamhost.com/ servers. Out of the box Vlad works with mongrel+apache+svn. Unfortunately Dreamhost uses apache+fastcgi, but thankfully tweaking Vlad was a piece of cake.

I followed the instructions on the “examples”:http://rubyhitsquad.com/Examples.html page for Vlad, but ultimately found I needed to do a little tweaking for my environment. Based on those basic examples I ended up making the following changes to my Rakefile and deploy.rb recipe file.

Here’s what I appended to my Rakefile:

# appended to my Rakefile
require 'vlad'
Vlad.load(:app => :apache)

Here’s my config/deploy.rb file:

set :domain,      "continuousthinking.com"
set :deploy_to,   "/my/path/to/continuousthinking.com/"
set :repository,  "http://myserver/svn/continuousthinking.com/trunk"
set :web_command, "echo skipping web "

namespace :vlad do
  remote_task :start_app do
    run "pkill -f dispatch.fcgi"
    fork do
      puts "sending a request to the domain so dispatchers restart"
      `wget http://#{domain} -O /dev/null`
    end
  end

  remote_task :update do
    Rake::Task['vlad:after_update'].invoke
  end

  remote_task :after_update do
    run "ln -s #{deploy_to}/shared/system/database.yml #{deploy_to}/current/config/database.yml"
    run "rm -f /home/zdennis/continuousthinking.com &&
         ln -s #{deploy_to}/current /home/zdennis/continuousthinking.com"      
  end

  remote_task :deploy => [:update, :start_app]
end

I overrode the :web_command setting so Vlad didn’t try to restart apache. The other tasks were added to customize specific needs for the deployment of the blog:

  • :start_app - kill all of dispatchers on Dreamhost and then send a request to have Dreamhost launch new ones
  • :update - adds this task to the :update task call chain. This simulates an after_update.
  • :after_update - create symlinks, etc to be performed after code has been updated.
  • :deploy - update code and restart the app

Overall, it was a pleasant process. I give Vlad a +1.


blog comments powered by Disqus