On 04/08/2011 12:31 PM, Mohammed Morsi wrote:
src/dbomatic/dbomatic | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic index 1cd1229..3ab9a4f 100755 --- a/src/dbomatic/dbomatic +++ b/src/dbomatic/dbomatic @@ -248,6 +248,14 @@ class CondorEventLog< Nokogiri::XML::SAX::Document end
def parse_log_file(log_file, parser)
- # if the log file has been rotated out (condor does this internally)
- if log_file.pos> File.size(CONDOR_EVENT_LOG_FILE)
- # since the original file descriptor is pointing at the log
- # just rotated out, we need to close and reopen
- log_file.close
- log_file = File.open(CONDOR_EVENT_LOG_FILE)
- end
- while s = log_file.gets parser<< s end
Three things -
0) You may want to do something with ino or ctime for rotation detection. It will be far more robust.
1) Be sure to read the rest of the events in the current log file before opening the new one.
2) You'll want to also make sure that rotation happens infrequently enough (compared to your polling rate) that you do not miss a rotation.
Best,
matt