---
src/dbomatic/dbomatic | 51 +++++++++++++++++++++++++++++++-----------------
1 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index 1cd1229..40cadb0 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -254,6 +254,21 @@ def parse_log_file(log_file, parser)
File.open(EVENT_LOG_POS_FILE, 'w') { |f| f.write log_file.pos.to_s }
end
+def setup_event_file_notifications(notifier, parser, log_file)
+ # Setup inotify watch for condor event log
+ notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
+ logger.info "modified: #{CONDOR_EVENT_LOG_FILE}"
+ parse_log_file log_file, parser
+ }
+ # adjust parser if log file has been truncated
+ notifier.watch(CONDOR_EVENT_LOG_FILE, :close_write){ |event|
+ if File.size(CONDOR_EVENT_LOG_FILE) == 0
+ setup_event_file_notifications(notifier, parser, log_file)
+ logger.info "close_write: #{CONDOR_EVENT_LOG_FILE}"
+ end
+ }
+end
+
begin
DBOMATIC_PID_FILE = "#{dbomatic_pid_dir}/dbomatic.pid"
FileUtils.mkdir_p File.dirname(DBOMATIC_PID_FILE)
@@ -282,26 +297,26 @@ begin
logger.info "done"
end
- # Setup inotify watch for condor event log
- notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
- parse_log_file log_file, parser
- }
-
- # if log file doesn't exist wait until it does
- else
- notifier.watch(condor_event_log_dir, :create){ |event|
- if event.name == "EventLog"
- log_file = File.open(CONDOR_EVENT_LOG_FILE)
- parse_log_file log_file, parser
-
- # Setup inotify watch for condor event log
- notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
- parse_log_file log_file, parser
- }
- end
- }
+ setup_event_log_notifications notifier, parser, log_file
end
+ # if log file doesn't exist wait until it does
+ notifier.watch(condor_event_log_dir, :create){ |event|
+ if event.name == "EventLog"
+ logger.info "created: EVENTLOG"
+ log_file = File.open(CONDOR_EVENT_LOG_FILE)
+ parse_log_file log_file, parser
+ setup_event_log_notifications notifier, parser, log_file
+ end
+ }
+
+ notifier.watch(condor_event_log_dir, :delete, :moved_from){ |event|
+ if event.name == "EventLog"
+ logger.info "deleted: EVENTLOG"
+ File.open(EVENT_LOG_POS_FILE, 'w') { |f| f.write "0" }
+ end
+ }
+
while true
begin
notifier.run
--
1.7.2.3
Show replies by date