def crawl(click_config, teacher_uri, registry_filepath, min_stake, network, learn_on_launch, provider_uri, influx_host, influx_port, dry_run): """ Gather NuCypher network information. """ # Banner emitter = click_config.emitter emitter.clear() emitter.banner(MONITOR_BANNER.format(CRAWLER)) registry = _get_registry(provider_uri, registry_filepath) # Teacher Ursula teacher_uris = [teacher_uri] if teacher_uri else None teacher_nodes = actions.load_seednodes( emitter, teacher_uris=teacher_uris, min_stake=min_stake, federated_only=False, network_domains={network} if network else None, network_middleware=click_config.middleware) # Configure Storage crawler = Crawler(domains={network} if network else None, network_middleware=RestMiddleware(), known_nodes=teacher_nodes, registry=registry, start_learning_now=True, learn_on_same_thread=learn_on_launch, blockchain_db_host=influx_host, blockchain_db_port=influx_port) if not dry_run: crawler.start() reactor.run()
def crawl( general_config, teacher_uri, registry_filepath, min_stake, network, learn_on_launch, provider_uri, influx_host, influx_port, http_port, dry_run, eager, poa, ): """ Gather NuCypher network information. """ # Banner emitter = general_config.emitter emitter.clear() emitter.banner(MONITOR_BANNER.format(CRAWLER)) # Setup BlockchainInterfaceFactory.initialize_interface(provider_uri=provider_uri, poa=poa) registry = _get_registry(registry_filepath, network) middleware = RestMiddleware() # Teacher Ursula sage_node = None if teacher_uri: sage_node = Ursula.from_teacher_uri( teacher_uri=teacher_uri, min_stake=0, # TODO: Where to get this? federated_only=False, # always False network_middleware=middleware, registry=registry) crawler = Crawler(domain=network if network else None, network_middleware=middleware, known_nodes=[sage_node] if teacher_uri else None, registry=registry, start_learning_now=eager, learn_on_same_thread=learn_on_launch, influx_host=influx_host, influx_port=influx_port) emitter.message(f"Network: {network.capitalize()}", color='blue') emitter.message(f"InfluxDB: {influx_host}:{influx_port}", color='blue') emitter.message(f"Provider: {provider_uri}", color='blue') emitter.message(f"Refresh Rate: {crawler._refresh_rate}s", color='blue') message = f"Running Nucypher Crawler JSON endpoint at http://localhost:{http_port}/stats" emitter.message(message, color='green', bold=True) if not dry_run: crawler.start(eager=eager) reactor.run()
def dashboard( click_config, host, http_port, registry_filepath, certificate_filepath, tls_key_filepath, provider_uri, network, influx_host, influx_port, dry_run, ): """ Run UI dashboard of NuCypher network. """ # Banner emitter = click_config.emitter emitter.clear() emitter.banner(MONITOR_BANNER.format(DASHBOARD)) registry = _get_registry(provider_uri, registry_filepath) # # WSGI Service # rest_app = Flask("monitor-dashboard") Dashboard(flask_server=rest_app, route_url='/', registry=registry, domain=network, blockchain_db_host=influx_host, blockchain_db_port=influx_port) # # Server # tls_hosting_power = _get_tls_hosting_power( host=host, tls_certificate_filepath=certificate_filepath, tls_private_key_filepath=tls_key_filepath) emitter.message(f"Running Monitor Dashboard - https://{host}:{http_port}") deployer = tls_hosting_power.get_deployer(rest_app=rest_app, port=http_port) if not dry_run: deployer.run()
def dashboard( general_config, host, http_port, registry_filepath, certificate_filepath, tls_key_filepath, provider_uri, network, influx_host, influx_port, crawler_host, crawler_port, dry_run, poa, ): """ Run UI dashboard of NuCypher network. """ # Banner emitter = general_config.emitter emitter.clear() emitter.banner(MONITOR_BANNER.format(DASHBOARD)) # Setup BlockchainInterfaceFactory.initialize_interface(provider_uri=provider_uri, poa=poa) registry = _get_registry(registry_filepath, network) # # WSGI Service # if not influx_host: influx_host = crawler_host rest_app = Flask("monitor-dashboard") if general_config.debug: os.environ['FLASK_ENV'] = 'development' Dashboard(flask_server=rest_app, route_url='/', registry=registry, network=network, influx_host=influx_host, influx_port=influx_port, crawler_host=crawler_host, crawler_port=crawler_port) # # Server # deployer = _get_deployer(rest_app=rest_app, host=host, port=http_port, certificate_filepath=certificate_filepath, tls_key_filepath=tls_key_filepath) # Pre-Launch Info emitter.message(f"Network: {network.capitalize()}", color='blue') emitter.message(f"Crawler: {crawler_host}:{crawler_port}", color='blue') emitter.message(f"InfluxDB: {influx_host}:{influx_port}", color='blue') emitter.message(f"Provider: {provider_uri}", color='blue') if not dry_run: emitter.message( f"Running Monitor Dashboard - https://{host}:{http_port}", color='green', bold=True) try: deployer.run() # <--- Blocking finally: click.secho("Shutting Down")