Mephisto capistrano tasks
The latest edition of Mephisto, Immortus, has just been released. I just upgraded this blog in 15 seconds to the latest edition by running one custom capistrano task.
Background
I keep my Mephisto theme in a subversion repository. My mephisto installation and my theme site in the same directory on the server.
$ ls /var/rails
depixelate depixelate_theme
With that layout in mind, here is my deploy.rb which I added to my depixelate_theme code.
deploy.rb
#
# Usage: $cap -r deploy.rb -a theme_update
#
set :rails_apps_dir, '/var/rails'
set :application, 'depixelate'
set :app_dir, "#{rails_apps_dir}/#{application}"
set :app_theme_dir, "#{rails_apps_dir}/#{application}_theme"
role :web, 'www.depixelate.com'
desc "Svn update on mephisto."
task :update_mephisto, :roles => :web do
run <<-CMD
cd #{app_dir} &&
svn update &&
RAILS_ENV=production rake db:migrate
CMD
theme_update
sudo '/etc/init.d/mongrel_cluster restart'
end
desc "Svn update the theme."
task :theme_update, :roles => :web do
run <<-CMD
cd #{app_theme_dir} &&
svn up &&
cd #{app_dir}/themes &&
ln -fs ../../#{application}_theme site-1 &&
cd #{app_dir} &&
./script/runner 'CachedPage.find(:all).each { |p| ActionController::Base.expire_page(p.url) }' -e production &&
./script/runner 'CachedPage.delete_all;' -e production &&
if [ -e #{app_dir}/public/stylesheets/depixelate.css ]; then rm #{app_dir}/public/stylesheets/depixelate.css; fi
CMD
end
Update - 9/2
I want to mention that this recipe is inspired by Geoffrey Grosenbach's capistrano task detailed in his Update Your Typo Blog With Capistrano article.


2 Comments
Great tip!
I use a similar setup with that other Rails blog software. I simplified it a bit by making a rake task out of the cache sweeping code so I just have to call 'rake sweep_cache'.
I also made a plugin with site-specific tasks. I can put things in there that should be run by cron and it gets updated along with the rest of the code.
Thanks topfunky - the recipe is inspired by your original Typo article. I referenced the article in the previous post and I updated this post to reflect it's origin.
Also, I do like the idea of a rake task to simplify things.
Commenting is closed for this article.