mirror of https://github.com/nucypher/nucypher.git
--debug ursula flag controls logging observers
parent
db1e3b3573
commit
e8aa9c5f9a
|
@ -53,10 +53,10 @@ from nucypher.blockchain.eth.deployers import (NucypherTokenDeployer,
|
||||||
PolicyManagerDeployer)
|
PolicyManagerDeployer)
|
||||||
from nucypher.characters.lawful import Ursula
|
from nucypher.characters.lawful import Ursula
|
||||||
from nucypher.config.characters import UrsulaConfiguration
|
from nucypher.config.characters import UrsulaConfiguration
|
||||||
from nucypher.config.constants import SEEDNODES
|
from nucypher.config.constants import SEEDNODES, USER_LOG_DIR
|
||||||
from nucypher.config.keyring import NucypherKeyring
|
from nucypher.config.keyring import NucypherKeyring
|
||||||
from nucypher.config.node import NodeConfiguration
|
from nucypher.config.node import NodeConfiguration
|
||||||
from nucypher.utilities.logging import logToSentry, getTextFileObserver
|
from nucypher.utilities.logging import logToSentry, getTextFileObserver, simpleObserver
|
||||||
from nucypher.utilities.sandbox.ursula import UrsulaCommandProtocol
|
from nucypher.utilities.sandbox.ursula import UrsulaCommandProtocol
|
||||||
|
|
||||||
BANNER = """
|
BANNER = """
|
||||||
|
@ -1015,15 +1015,25 @@ def ursula(config,
|
||||||
"""
|
"""
|
||||||
log = Logger("ursula/launch")
|
log = Logger("ursula/launch")
|
||||||
|
|
||||||
|
# NOTE: Requires ~1GB free memory
|
||||||
password = os.environ.get(config._KEYRING_PASSPHRASE_ENVVAR, None)
|
password = os.environ.get(config._KEYRING_PASSPHRASE_ENVVAR, None)
|
||||||
if not password:
|
if not password:
|
||||||
password = click.prompt("Password to unlock Ursula's keyring", hide_input=True)
|
password = click.prompt("Password to unlock Ursula's keyring", hide_input=True)
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
|
||||||
|
# Sentry
|
||||||
|
globalLogPublisher.removeObserver(logToSentry)
|
||||||
|
config.log_to_sentry = False
|
||||||
|
|
||||||
|
# Print
|
||||||
|
globalLogPublisher.addObserver(simpleObserver)
|
||||||
|
|
||||||
def __make_ursula():
|
def __make_ursula():
|
||||||
if not checksum_address and not config.dev:
|
if not checksum_address and not config.dev:
|
||||||
raise click.BadArgumentUsage("No Configuration file found, and no --checksum address <addr> was provided.")
|
raise click.BadArgumentUsage("No Configuration file found, and no --checksum address <addr> was provided.")
|
||||||
if not checksum_address and not config.dev:
|
if not checksum_address and not config.dev:
|
||||||
raise click.BadOptionUsage(message="No account specified. pass --checksum-address, --dev, "
|
raise click.BadParameter(message="No account specified. pass --checksum-address, --dev, "
|
||||||
"or use a configuration file with --config-file <path>")
|
"or use a configuration file with --config-file <path>")
|
||||||
|
|
||||||
return UrsulaConfiguration(temp=config.dev,
|
return UrsulaConfiguration(temp=config.dev,
|
||||||
|
@ -1054,7 +1064,10 @@ def ursula(config,
|
||||||
filepath = config.config_file or UrsulaConfiguration.DEFAULT_CONFIG_FILE_LOCATION
|
filepath = config.config_file or UrsulaConfiguration.DEFAULT_CONFIG_FILE_LOCATION
|
||||||
click.secho("Reading Ursula node configuration file {}".format(filepath), fg='blue')
|
click.secho("Reading Ursula node configuration file {}".format(filepath), fg='blue')
|
||||||
ursula_config = UrsulaConfiguration.from_configuration_file(filepath=filepath)
|
ursula_config = UrsulaConfiguration.from_configuration_file(filepath=filepath)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
||||||
|
# Continue without a configuration file
|
||||||
ursula_config = __make_ursula()
|
ursula_config = __make_ursula()
|
||||||
|
|
||||||
config.operating_mode = "federated" if ursula_config.federated_only else "decentralized"
|
config.operating_mode = "federated" if ursula_config.federated_only else "decentralized"
|
||||||
|
@ -1113,14 +1126,15 @@ def ursula(config,
|
||||||
|
|
||||||
# GO!
|
# GO!
|
||||||
click.secho("Running Ursula on {}".format(URSULA.rest_interface), fg='green', bold=True)
|
click.secho("Running Ursula on {}".format(URSULA.rest_interface), fg='green', bold=True)
|
||||||
|
if not debug:
|
||||||
stdio.StandardIO(UrsulaCommandProtocol(ursula=URSULA))
|
stdio.StandardIO(UrsulaCommandProtocol(ursula=URSULA))
|
||||||
URSULA.get_deployer().run()
|
URSULA.get_deployer().run()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
config.log.critical(str(e))
|
config.log.critical(str(e))
|
||||||
click.secho("{} {}".format(e.__class__.__name__, str(e)), fg='red')
|
click.secho("{} {}".format(e.__class__.__name__, str(e)), fg='red')
|
||||||
if debug: raise
|
raise # Crash
|
||||||
raise click.Abort()
|
|
||||||
finally:
|
finally:
|
||||||
click.secho("Stopping Ursula")
|
click.secho("Stopping Ursula")
|
||||||
ursula_config.cleanup()
|
ursula_config.cleanup()
|
||||||
|
|
|
@ -36,7 +36,8 @@ from nucypher.network.middleware import RestMiddleware
|
||||||
|
|
||||||
|
|
||||||
class NodeConfiguration:
|
class NodeConfiguration:
|
||||||
_name = 'ursula' # TODO: un-hardcode Ursula
|
|
||||||
|
_name = 'ursula'
|
||||||
_character_class = Ursula
|
_character_class = Ursula
|
||||||
|
|
||||||
DEFAULT_CONFIG_FILE_LOCATION = os.path.join(DEFAULT_CONFIG_ROOT, '{}.config'.format(_name))
|
DEFAULT_CONFIG_FILE_LOCATION = os.path.join(DEFAULT_CONFIG_ROOT, '{}.config'.format(_name))
|
||||||
|
|
Loading…
Reference in New Issue