Posts Tagged ‘capistrano’

Been having problems with swap space and memory on my slicehost servers. And it is all apache's and mongrel's fault. That used to be the cool combination and now it is an ugly, sluggish beast. Just recently, I switched to nginx (to replace apache) and thin (to replace mongrel). So far so good, major speed improvements and definitely memory consumption improvements.

I started out by switching everything over the nginx while keeping the mongrels alive, that was actually pretty easy. Information was available everywhere.

Thinning everything via capistrano took a while, that wasn't as well documented. Thin was documented, capistrano was documented, but easy solutions as to how to combine the two were difficult to find.

deploy.task:after_update_code, :roles=>[:web]do
desc "Copying the right mongrel cluster config for the current stage environment."
run "cp -f #{release_path}/config/mongrel_#{stage}.yml #{release_path}/config/mongrel_cluster.yml"end

... <other things like symlinks>

Now that we are moving from mongrel to thin, no need for two lines in particular, one being the line that requires mongrel_cluster recipes and the other that sets the mongrel_cluster yaml config path. A third line changes from mongrel_cluster.yml to thin_cluster.yml. You get something like this:

set :stages, %w(staging production)
set :default_stage, "production"

require"capistrano/ext/multistage"

set :application, "myapplication.com"
set :user, "appuser"

set :repository, "http://svn.myapplication.com/myapp/trunk"
set :deploy_to, "/var/www/#{application}"

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