def config(general_config, config_options, config_file): """ View and optionally update the Ursula node's configuration. """ emitter = _setup_emitter(general_config, config_options.worker_address) if not config_file: config_file = select_config_file( emitter=emitter, checksum_address=config_options.worker_address, config_class=UrsulaConfiguration) emitter.echo(f"Ursula Configuration {config_file} \n {'='*55}") return get_or_update_configuration(emitter=emitter, config_class=UrsulaConfiguration, filepath=config_file, config_options=config_options)
def destroy(general_config, config_options, config_file, force): """ Delete Ursula node configuration. """ emitter = _setup_emitter(general_config, config_options.worker_address) _pre_launch_warnings(emitter, dev=config_options.dev, force=force) if not config_file: config_file = select_config_file( emitter=emitter, checksum_address=config_options.worker_address, config_class=UrsulaConfiguration) ursula_config = config_options.create_config(emitter, config_file) actions.destroy_configuration(emitter, character_config=ursula_config, force=force)
def run(general_config, character_options, config_file, interactive, dry_run, metrics_port, prometheus): """Run an "Ursula" node.""" worker_address = character_options.config_options.worker_address emitter = _setup_emitter(general_config, worker_address=worker_address) _pre_launch_warnings(emitter, dev=character_options.config_options.dev, force=None) if not character_options.config_options.dev and not config_file: config_file = select_config_file(emitter=emitter, checksum_address=worker_address, config_class=UrsulaConfiguration) ursula_config, URSULA = character_options.create_character( emitter=emitter, config_file=config_file, json_ipc=general_config.json_ipc) return URSULA.run(emitter=emitter, start_reactor=not dry_run, interactive=interactive, prometheus=prometheus)
def run(general_config, character_options, config_file, interactive, dry_run, metrics_port): """ Run an "Ursula" node. """ # # Setup # worker_address = character_options.config_options.worker_address emitter = _setup_emitter(general_config, worker_address=worker_address) _pre_launch_warnings(emitter, dev=character_options.config_options.dev, force=None) if not character_options.config_options.dev and not config_file: config_file = select_config_file(emitter=emitter, checksum_address=worker_address, config_class=UrsulaConfiguration) ursula_config, URSULA = character_options.create_character( emitter=emitter, config_file=config_file, json_ipc=general_config.json_ipc) # # Additional Services # if interactive: stdio.StandardIO(UrsulaCommandProtocol(ursula=URSULA, emitter=emitter)) if metrics_port: # Prevent import without prometheus installed from nucypher.utilities.metrics import initialize_prometheus_exporter initialize_prometheus_exporter( ursula=URSULA, port=metrics_port) # TODO: Integrate with Hendrix TLS Deploy? # # Deploy Warnings # emitter.message(f"Starting Ursula on {URSULA.rest_interface}", color='green', bold=True) emitter.message(f"Connecting to {','.join(ursula_config.domains)}", color='green', bold=True) emitter.message("Working ~ Keep Ursula Online!", color='blue', bold=True) # Run try: if dry_run: # Prevent the cataloging of services, and do not run the reactor return # <-- ABORT - (Last Chance) node_deployer = URSULA.get_deployer() node_deployer.addServices() node_deployer.catalogServers(node_deployer.hendrix) node_deployer.run() # <--- Blocking Call (Reactor) # Handle Crash except Exception as e: ursula_config.log.critical(str(e)) emitter.message(f"{e.__class__.__name__} {e}", color='red', bold=True) raise # Crash :-( # Graceful Exit finally: emitter.message("Stopping Ursula", color='green') ursula_config.cleanup() emitter.message("Ursula Stopped", color='red')