Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mongrel: script/server tails the rails log like it does with lighttpd. …
…Closes #5541. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4506 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
4 changed files
with
29 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
def tail(log_file) | ||
cursor = File.size(log_file) | ||
last_checked = Time.now | ||
tail_thread = Thread.new do | ||
File.open(log_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 | ||
end | ||
sleep 1 | ||
end | ||
end | ||
end | ||
tail_thread | ||
end |
This file contains 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
This file contains 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