# File lib/thin/controllers/controller.rb, line 142 def tail(file) cursor = File.exist?(file) ? File.size(file) : 0 last_checked = Time.now tail_thread = Thread.new do Thread.pass until File.exist?(file) File.open(file, 'r') do |f| loop do f.seek cursor if f.mtime > last_checked last_checked = f.mtime contents = f.read cursor += contents.length print contents STDOUT.flush end sleep 0.1 end end end sleep 1 if File.exist?(file) # HACK Give the thread a little time to open the file tail_thread end