I’m really REALLY good at getting distracted. Recently I have adopted the Pomodoro Techinque developed by Francesco Cirillo. To track my pomodoros I’ve been using this software from developer Ugo Landini. This in itself has really made a difference to my level of focus – gotta get those pomodoros complete – but I have just recently discovered another tool that works as a great complement to the pomodoro technique/software, it’s an application called Divvy. Divvy lets you divide your screen up and position windows the way you want. Because I have all of my development reference books in PDF format, it works great having the left half of my screen with documentation and the right half of the screen with my code editor. This really helps to keep me on task and avoid distractions. I highly recommend both of these apps – and of course using the Pomodoro Technique!

Tagged with:
 

Easy Rails Deploy with Vlad

On May 20, 2010, in Rails, by nancy

Vlad the Deployer makes it easy to deploy your Rails projects, however the documentation didn’t make it easy to cobble together the bits I needed. After Googling and reading I have successfully set up Vlad for my project so I’m documenting my process for anyone else that might need a hand.

Here’s my setup:

  • Git ( self-hosted Gitosis repository )
  • Rails 2.3.5
  • Vlad 2.0.2
  • Vlad-Git 2.1.0
  • Apache 2.2
  • Phusion Passenger 2.2.11
  • Debian Lenny ( Linode server )
  • Snow Leopard ( development machine )

  

Install Vlad

The Vlad gem supports Subversion so you also need to install the gem/plugin for Git support.

sudo gem install vlad
sudo gem install vlad-git

Import vlad’s Rake tasks. You can add this to your main Rakefile or create lib/tasks/vlad.rake.

begin
  require ‘vlad’
  Vlad.load :app => :passenger, :scm => :git
rescue LoadError
  # do nothing
end

  

rake vlad:setup

You only need to run this task once – to create the :deploy_to directory on the server. It should contain the following directory structure:

scm/
releases/
shared/log/
shared/pids/
shared/system/

  

config/deploy.rb

Because I don’t like to keep passwords in version control I set up a shared/config directory and put my database.yml there. I added a Rake task to my deploy.rb that copies the contents of my shared directory into the current release.

set :user, “deploy”
set :application, “myApp”
set :repository, “gitosis@myserver.com:#{application}.git”
set :deploy_to, “/path/to/#{application}”
set :domain, “#{user}@myserver.com”
set :web_command, “sudo apache2ctl”

namespace :vlad do
   remote_task :copy_config_files, :roles => :app do
      run “cp #{shared_path}/config/* #{current_path}/config/”
   end
end

namespace :vlad do
   task :deploy => %w[
     vlad:update
     vlad:copy_config_files
     vlad:migrate
     vlad:start
     vlad:cleanup
   ]
end

vlad tasks

  • rake vlad:setup – Used to set up the initial directory structure on the remote server.
  • rake vlad:update – Vlad removes everything from scm/repo and replaces it with a fresh clone of the Git repository and points the current symlink in the deploy directory to the new release.
  • rake vlad:migrate – This task runs rake db:migrate RAILS_ENV=production for the current deployment on the server.
  • rake vlad:start – This task restarts the application by touching tmp/restart.txt and restarts the web server using apache2ctl.
  • rake vlad:cleanup – This task will remove all but the last 5 deployed releases.
  • rake vlad:deploy – The Rake task for a full deploy.
Tagged with: