Merge "Modify watchdog related functionality"

This commit is contained in:
Jenkins 2014-06-16 23:42:47 +00:00 committed by Gerrit Code Review
commit fe595af499
2 changed files with 9 additions and 6 deletions

View File

@ -41,8 +41,8 @@ class Engine(object):
Engine.set_logger(**cfg_data)
# constants
# TODO(praneshp): Hardcode for now, could/should be cmdline input
self._engine_cfg_data = cfg_data
self.max_workers = 8
self._engine_cfg_data = cfg_data
self.audit_type = 'audit'
self.repair_type = 'repair'
self.entropy_exchange = Exchange('entropy_exchange', type='fanout')
@ -69,6 +69,7 @@ class Engine(object):
# Private variables to keep track of repair scripts.
self._repairs = []
self._known_routing_keys = set()
LOG.info('Created engine obj %s', self.name)
# TODO(praneshp): Move to utils?
@ -108,7 +109,7 @@ class Engine(object):
self.futures.append(scheduler)
# watchdog
watchdog_thread = self.start_watchdog(self.cfg_dir)
watchdog_thread = self.start_watchdog()
watchdog_thread.join()
def schedule(self):
@ -195,9 +196,10 @@ class Engine(object):
LOG.info('Repair configuration changed')
self.futures.extend(self.start_react_scripts())
def start_watchdog(self, dir_to_watch):
def start_watchdog(self):
LOG.debug('Watchdog mapping is: ', self._watchdog_event_fn)
return utils.watch_dir_for_change(dir_to_watch,
dirs_to_watch = [utils.get_filename_and_path(self.repair_cfg)[0]]
return utils.watch_dir_for_change(dirs_to_watch,
self._watchdog_event_fn)
def setup_audit(self, execution_time, audit_list):

View File

@ -105,10 +105,11 @@ class WatchdogHandler(FileSystemEventHandler):
LOG.error('no associated function for %s', event.src_path)
def watch_dir_for_change(dir_to_watch, event_fn):
def watch_dir_for_change(dirs_to_watch, event_fn):
event_handler = WatchdogHandler(event_fn)
observer = Observer()
observer.schedule(event_handler, path=dir_to_watch)
for directory in dirs_to_watch:
observer.schedule(event_handler, path=directory)
observer.start()
return observer