Capistrano - 'sanity_check' task


#1

I instantly refresh my browser after deploying to make sure nothing went
wrong. This gets tiring so I added some code to hit the site and print
results after the deployment task has been run. The Net:HTTP code is
taken
verbatim from the pickaxe Net:HTTP reference.

task :after_deploy, :roles => :app do
sanity_check
end

desc “Use Net:HTTP to pull up the live site”
task :sanity_check do
Net::HTTP.start(‘www.yoursite.com’) do |http|
response = http.get(’/’)
puts “Code = #{response.code}”
puts “Message = #{response.message}”
response.each do |key,val|
printf “%-14s = %-40.40s\n”, key, val
end
p response.body[400,500]
end
end