def run(self): """Lunch checks and triggers updates on BIRD configuration.""" # Lunch a thread for each configuration if not self.services: self.log.warning("no service checks are configured") else: self.log.info("going to lunch %s threads", len(self.services)) for service in self.services: self.log.debug("lunching thread for %s", service) _config = {} for option, getter in SERVICE_OPTIONS_TYPE.items(): _config[option] = getattr(self.config, getter)(service, option) _thread = ServiceCheck(service, _config, self.action) _thread.start() # Stay running until we are stopped while True: # Fetch items from action queue operation = self.action.get(block=True) self.log.info( "returned an item from the queue for %s with IP " "prefix %s and action to %s Bird configuration", operation.name, operation.ip_prefix, operation) bird_updated = self._update_bird_conf_file(operation) self.action.task_done() if bird_updated: ip_version = operation.ip_version cmd = self.bird_configuration[ip_version]['reconfigure_cmd'] reconfigure_bird(cmd)
def run(self): """Lunch checks and triggers updates on BIRD configuration.""" # Lunch a thread for each configuration if not self.services: self.log.warning("no service checks are configured") else: self.log.info("going to lunch %s threads", len(self.services)) if self.config.has_option('daemon', 'splay_startup'): splay_startup = self.config.getfloat('daemon', 'splay_startup') else: splay_startup = None for service in self.services: self.log.debug("lunching thread for %s", service) _config = {} for option, getter in SERVICE_OPTIONS_TYPE.items(): try: _config[option] = getattr(self.config, getter)(service, option) except NoOptionError: pass # for optional settings _thread = ServiceCheck(service, _config, self.action, splay_startup) _thread.start() # Stay running until we are stopped while True: # Fetch items from action queue operation = self.action.get(block=True) if isinstance(operation, ServiceCheckDiedError): self.log.critical(operation) self.log.critical("This is a fatal error and the only way to " "recover is to restart, thus exiting with a " "non-zero code and let systemd act by " "triggering a restart") sys.exit(1) self.log.info( "returned an item from the queue for %s with IP " "prefix %s and action to %s Bird configuration", operation.name, operation.ip_prefix, operation) bird_updated = self._update_bird_conf_file(operation) self.action.task_done() if bird_updated: ip_version = operation.ip_version if operation.bird_reconfigure_cmd is None: reconfigure_bird( self.bird_configuration[ip_version]['reconfigure_cmd']) else: run_custom_bird_reconfigure(operation)
def run(self): """Lunches checks and triggers updates on BIRD configuration.""" # Lunch a thread for each configuration if not self.services: self.log.warning("no service checks are configured") else: msg = "going to lunch {n} threads".format(n=len(self.services)) self.log.info(msg) for service in self.services: msg = "lunching thread for {n}".format(n=service) self.log.debug(msg, json_blob=False) _config = {} for option, getter in SERVICE_OPTIONS_TYPE.items(): _config[option] = getattr(self.config, getter)(service, option) _thread = ServiceCheck( service, _config, self.action, self.log) _thread.start() # Stay running until we are stopped while True: # Fetch items from action queue operation = self.action.get(block=True) msg = ("returned an item from the queue for {n} with IP prefix {i}" " and action to {o} Bird configuration" .format(n=operation.name, i=operation.ip_prefix, o=operation)) self.log.info(msg) bird_updated = self._update_bird_conf_file(operation) self.action.task_done() if bird_updated: reconfigure_bird( self.log, self.config.get('daemon', 'bird_reconfigure_cmd') )