public
Last active

Capistrano extra recipes

  • Download Gist
capistrano_log_recipes.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
namespace :log do
 
desc "A pinch of tail"
task :tailf, :roles => :app do
run "tail -n 10000 -f #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
 
 
desc "Grep actions and highlight long time actions > 300ms"
task :grep_long, :roles => :app do
run "grep '^Completed' #{shared_path}/log/#{rails_env}.log | tail -n 1000 | perl -pe 's/Completed in ([3-9][0-9]{2,}|1[0-9]{3,})+ms.+]/\e[1;33;44m$&\e[0m/g'" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
 
 
# gem install request-log-analyzer
desc "Request-log-analyzer"
task :rla, :roles => :app do
run "request-log-analyzer #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.