Skip to content

Instantly share code, notes, and snippets.

@fedeisas
Created November 29, 2013 19:14
Show Gist options
  • Save fedeisas/7710577 to your computer and use it in GitHub Desktop.
Save fedeisas/7710577 to your computer and use it in GitHub Desktop.
Capistrano server tail
namespace :server do
desc "Tail server log"
task :tail do
on roles(:app) do
trap("INT") { puts puts "\e[0;36mInterrupted\e[1;0m"; exit 0; }
trap("SIGINT") { puts puts "\e[0;36mInterrupted\e[1;0m"; exit 0; }
latest_log = capture(sprintf("ls -tr /var/www/%s/shared/app/storage/logs/*.txt | tail -1 | head -1", fetch(:stage)))
if(!latest_log.empty?)
tail_command = sprintf("tail -f -n10 %s", latest_log)
puts "\e[0;36mrunning tail -f -n10 #{latest_log}\e[1;0m"
execute("#{tail_command}")
else
puts "No log to tail."
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment