Capistrano With Rack

ruby capistrano deployment rack

Sun Nov 08 22:23:11 -0800 2009

Savorous, as well as killthe.net, is built on the Sinatra framework and served via Apache and the Passenger extension, with Rack somewhere in the middle.

By default, the application will be loaded with the production environment unless you specify otherwise. I do so in the application’s rackup file, config.ru, like so:

require 'savorous'

set :environment, :development

run Sinatra::Application

But of course that’s not appropriate for production. So I have a second file, config.ru.production, and in my config/deploy.rb, which the Capfile calls, I have:

namespace :configure do
	desc "Putting production rackup file in place"
	task :rackup, :roles => :app do
		run "rm #{File.join(current_path,'config.ru')}"
		run "mv #{File.join(current_path,'config.ru.production')} #{File.join(current_path,'config.ru')}"
	end
end

after("deploy:symlink") do
	configure.rackup
end

I’m still learning all the ins and outs of Capistrano, so this may not be the best way to do it (though it works). I simply looked for the last task to occur before restart was called and inserted my configure.rackup call there. Good enough!

blog comments powered by Disqus