def run_agent(self): self.__log.info("Starting Cartridge Agent...") # Start topology event receiver thread self.register_topology_event_listeners() if Config.lvs_virtual_ip is None or str(Config.lvs_virtual_ip).strip() == "": self.__log.debug("LVS Virtual IP is not defined") else: event_handler.create_dummy_interface() # request complete topology event from CC by publishing CompleteTopologyRequestEvent publisher.publish_complete_topology_request_event() # wait until complete topology message is received to get LB IP self.wait_for_complete_topology() # wait for member initialized event while not Config.initialized: self.__log.debug("Waiting for cartridge agent to be initialized...") time.sleep(1) # Start instance notifier listener thread self.register_instance_topic_listeners() # Start tenant event receiver thread self.register_tenant_event_listeners() # start application signup event listener self.register_application_signup_event_listeners() # request complete tenant event from CC by publishing CompleteTenantRequestEvent publisher.publish_complete_tenant_request_event() # Execute instance started shell script event_handler.on_instance_started_event() # Publish instance started event publisher.publish_instance_started_event() # Execute start servers extension try: event_handler.start_server_extension() except Exception as ex: self.__log.exception("Error processing start servers event: %s" % ex) # check if artifact management is required before publishing instance activated event repo_url = Config.repo_url if repo_url is None or str(repo_url).strip() == "": self.__log.info("No artifact repository found") publisher.publish_instance_activated_event() event_handler.on_instance_activated_event() else: # instance activated event will be published in artifact updated event handler self.__log.info( "Artifact repository found, waiting for artifact updated event to checkout artifacts: [repo_url] %s", repo_url) persistence_mapping_payload = Config.persistence_mappings if persistence_mapping_payload is not None: event_handler.volume_mount_extension(persistence_mapping_payload) # start log publishing thread log_publish_manager = None if DataPublisherConfiguration.get_instance().enabled: log_file_paths = Config.log_file_paths if log_file_paths is None: self.__log.exception("No valid log file paths found, no logs will be published") else: self.__log.debug("Starting Log Publisher Manager: [Log file paths] %s" % ", ".join(log_file_paths)) log_publish_manager = LogPublisherManager(log_file_paths) log_publish_manager.start() # run until terminated while not self.__terminated: time.sleep(5) if DataPublisherConfiguration.get_instance().enabled: log_publish_manager.terminate_all_publishers()
def run_agent(self): self.__log.info("Starting Cartridge Agent...") # Start topology event receiver thread self.register_topology_event_listeners() if Config.lvs_virtual_ip is None or str( Config.lvs_virtual_ip).strip() == "": self.__log.debug("LVS Virtual IP is not defined") else: event_handler.create_dummy_interface() # request complete topology event from CC by publishing CompleteTopologyRequestEvent publisher.publish_complete_topology_request_event() # wait until complete topology message is received to get LB IP self.wait_for_complete_topology() # wait for member initialized event while not Config.initialized: self.__log.debug( "Waiting for cartridge agent to be initialized...") time.sleep(1) # Start instance notifier listener thread self.register_instance_topic_listeners() # Start tenant event receiver thread self.register_tenant_event_listeners() # start application signup event listener self.register_application_signup_event_listeners() # request complete tenant event from CC by publishing CompleteTenantRequestEvent publisher.publish_complete_tenant_request_event() # Execute instance started shell script event_handler.on_instance_started_event() # Publish instance started event publisher.publish_instance_started_event() # Execute start servers extension try: event_handler.start_server_extension() except Exception as ex: self.__log.exception("Error processing start servers event: %s" % ex) # check if artifact management is required before publishing instance activated event repo_url = Config.repo_url if repo_url is None or str(repo_url).strip() == "": self.__log.info("No artifact repository found") publisher.publish_instance_activated_event() event_handler.on_instance_activated_event() else: # instance activated event will be published in artifact updated event handler self.__log.info( "Artifact repository found, waiting for artifact updated event to checkout artifacts: [repo_url] %s", repo_url) persistence_mapping_payload = Config.persistence_mappings if persistence_mapping_payload is not None: event_handler.volume_mount_extension(persistence_mapping_payload) # start log publishing thread log_publish_manager = None if DataPublisherConfiguration.get_instance().enabled: log_file_paths = Config.log_file_paths if log_file_paths is None: self.__log.exception( "No valid log file paths found, no logs will be published") else: self.__log.debug( "Starting Log Publisher Manager: [Log file paths] %s" % ", ".join(log_file_paths)) log_publish_manager = LogPublisherManager(log_file_paths) log_publish_manager.start() # run until terminated while not self.__terminated: time.sleep(5) if DataPublisherConfiguration.get_instance().enabled: log_publish_manager.terminate_all_publishers()