This is my Blog.

It's full of opinions on a wide range of stuff.

Deploying Ruby WebGen with Capistrano

WebGen is a groovy little tool that makes building HTML sites a lot simpler, and makes maintenance a lot more efficient via clever templating. I wont labour the pro's and con's of the project here, I'll just get on with explaining how to deploy version webgen sites using our good friend Capistrano.

First off, install Capistrano:

<code>$ sudo gem install capistrano -y</code>

Next, we need to prepar our webgen dir with all the relevant deployment information. All these commands presume you have ‘cd' to the webgen project directory Capistrano provides a simple way to do this

<code>$ mkdir config
$ capify .</code>

Next we need to setup our new deploy.rb file, mine looks a little something like this:

set :application, "" 
set :repository,  "svn://yourhost/path/to/webgen/site/output" 

# If you aren't deploying to /u/apps/#{application} on the
# target servers (which is the default), you can specify 
# the actual location via the :deploy_to variable:
set :deploy_to, "/var/www/sites/#{application}" 

# If you aren't using Subversion to manage your 
# source code, specify your SCM below:
# set :scm, :subversion
set :user, "deploy" 
set :svn_user, "badger" 

role :app, "" 
role :web, "" 
role :db,  "", :primary => true

# Overrides the default task supplied by cap, as this 
# is a static site there are no mongrel's et al 
# that need restarting
desc "Deploy webgen site" 
deploy.task :restart do
  puts "Using webgen, so nothing to restart" 

# also, because we have configured logging via our HTTP 
# server (e.g. nginx, apache etc) we have no need for this 
# part of the deployment phase to we again, just override it
# with an arbitrary message
desc "Override default cap behavior for finalize_update" 
deploy.task :finalize_update do
  puts "We dont need no stinking logs..." 

Now, all being well, we need to setup the server to respond to cap:

<code>$ cap deploy:setup</code>

Then we should be able to deploy our project with no problems!

<code>$ cap deploy</code>

I hope this was of use to someone, somewhere, sometime :)

blog comments powered by Disqus