Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

reopen when file inode changes

  • Loading branch information...
commit 30b9462cb23f4f0dcd8dc28893fe116a0c789ee7 1 parent bd36e36
Ryan King ryanking authored jkalucki committed

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. +8 3 bin/jvm-gc-stats.rb
11 bin/jvm-gc-stats.rb
@@ -9,10 +9,14 @@
9 9 ALL_MEASUREMENTS = %w[promoFail.realSec major.concur.userSec major.concur.realSec major.block.userSec] +
10 10 %w[%s.survivalRatio %s.kbytesPerSec %s.userSec %s.realSec].collect{|m| %w[minor full].collect{|s| m % s}}.flatten
11 11
12   -def tail(file)
  12 +def open_file(file)
13 13 f = File.new(file, "r")
14   - f.seek(0, IO::SEEK_END) if TAIL_ONLY
  14 +end
15 15
  16 +def tail(file)
  17 + f = open_file(file)
  18 + f.seek(0, IO::SEEK_END) if TAIL_ONLY
  19 + current_inode = f.stat.ino
16 20 lines = ""
17 21 loop do
18 22 begin
@@ -23,7 +27,8 @@ def tail(file)
23 27 # End of file reached, wait for more data
24 28 ALL_MEASUREMENTS.each{|m| report(m, 0)}
25 29 sleep TAIL_SLEEP_SEC
26   - #TODO stat file to see if inode changed
  30 + f = open(file) unless File.stat(file).ino == current_inode
  31 + current_inode = f.stat.ino
27 32 else
28 33 lines += part
29 34 end

0 comments on commit 30b9462

Please sign in to comment.
Something went wrong with that request. Please try again.