def _prepare_start(self) -> None: log_queue = self.context.boot_kwargs['log_queue'] level = self.context.boot_kwargs.get('log_level', logging.INFO) setup_queue_logging(log_queue, level) self.event_bus.connect_no_wait() self.event_bus.broadcast(PluginStartedEvent(type(self))) with self.context.trinity_config.process_id_file(self.normalized_name): self.do_start()
def _spawn_start(self) -> None: log_queue = self.boot_info.boot_kwargs['log_queue'] level = self.boot_info.boot_kwargs.get('log_level', logging.INFO) setup_queue_logging(log_queue, level) if self.boot_info.args.log_levels: setup_log_levels(self.boot_info.args.log_levels) with self.boot_info.trinity_config.process_id_file(self.normalized_name): loop = asyncio.get_event_loop() asyncio.ensure_future(self._prepare_start()) loop.run_forever() loop.close()
def _prepare_start(self) -> None: log_queue = self.context.boot_kwargs['log_queue'] level = self.context.boot_kwargs.get('log_level', logging.INFO) setup_queue_logging(log_queue, level) connection_config = ConnectionConfig.from_name( self.normalized_name, self.context.trinity_config.ipc_dir) self.event_bus.start_serving_nowait(connection_config) self.event_bus.connect_to_endpoints_blocking( ConnectionConfig.from_name(MAIN_EVENTBUS_ENDPOINT, self.context.trinity_config.ipc_dir)) # This makes the `main` process aware of this Endpoint which will then propagate the info # so that every other Endpoint can connect directly to the plugin Endpoint self.event_bus.announce_endpoint() self.event_bus.broadcast(PluginStartedEvent(type(self))) # Whenever new EventBus Endpoints come up the `main` process broadcasts this event # and we connect to every Endpoint directly self.event_bus.auto_connect_new_announced_endpoints() with self.context.trinity_config.process_id_file(self.normalized_name): self.do_start()
def _setup_logging(self) -> None: log_queue = self.boot_info.boot_kwargs['log_queue'] level = self.boot_info.boot_kwargs.get('log_level', logging.INFO) setup_queue_logging(log_queue, level) if self.boot_info.args.log_levels: setup_log_levels(self.boot_info.args.log_levels)