Created
November 29, 2013 19:14
-
-
Save fedeisas/7710577 to your computer and use it in GitHub Desktop.
Capistrano server tail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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