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)
|
||||
from nucypher.characters.lawful import Ursula
|
||||
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.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
|
||||
|
||||
BANNER = """
|
||||
|
@ -1015,16 +1015,26 @@ def ursula(config,
|
|||
"""
|
||||
log = Logger("ursula/launch")
|
||||
|
||||
# NOTE: Requires ~1GB free memory
|
||||
password = os.environ.get(config._KEYRING_PASSPHRASE_ENVVAR, None)
|
||||
if not password:
|
||||
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():
|
||||
if not checksum_address and not config.dev:
|
||||
raise click.BadArgumentUsage("No Configuration file found, and no --checksum address <addr> was provided.")
|
||||
if not checksum_address and not config.dev:
|
||||
raise click.BadOptionUsage(message="No account specified. pass --checksum-address, --dev, "
|
||||
"or use a configuration file with --config-file <path>")
|
||||
raise click.BadParameter(message="No account specified. pass --checksum-address, --dev, "
|
||||
"or use a configuration file with --config-file <path>")
|
||||
|
||||
return UrsulaConfiguration(temp=config.dev,
|
||||
auto_initialize=config.dev,
|
||||
|
@ -1054,7 +1064,10 @@ def ursula(config,
|
|||
filepath = config.config_file or UrsulaConfiguration.DEFAULT_CONFIG_FILE_LOCATION
|
||||
click.secho("Reading Ursula node configuration file {}".format(filepath), fg='blue')
|
||||
ursula_config = UrsulaConfiguration.from_configuration_file(filepath=filepath)
|
||||
|
||||
except FileNotFoundError:
|
||||
|
||||
# Continue without a configuration file
|
||||
ursula_config = __make_ursula()
|
||||
|
||||
config.operating_mode = "federated" if ursula_config.federated_only else "decentralized"
|
||||
|
@ -1113,14 +1126,15 @@ def ursula(config,
|
|||
|
||||
# GO!
|
||||
click.secho("Running Ursula on {}".format(URSULA.rest_interface), fg='green', bold=True)
|
||||
stdio.StandardIO(UrsulaCommandProtocol(ursula=URSULA))
|
||||
if not debug:
|
||||
stdio.StandardIO(UrsulaCommandProtocol(ursula=URSULA))
|
||||
URSULA.get_deployer().run()
|
||||
|
||||
except Exception as e:
|
||||
config.log.critical(str(e))
|
||||
click.secho("{} {}".format(e.__class__.__name__, str(e)), fg='red')
|
||||
if debug: raise
|
||||
raise click.Abort()
|
||||
raise # Crash
|
||||
|
||||
finally:
|
||||
click.secho("Stopping Ursula")
|
||||
ursula_config.cleanup()
|
||||
|
|
|
@ -36,7 +36,8 @@ from nucypher.network.middleware import RestMiddleware
|
|||
|
||||
|
||||
class NodeConfiguration:
|
||||
_name = 'ursula' # TODO: un-hardcode Ursula
|
||||
|
||||
_name = 'ursula'
|
||||
_character_class = Ursula
|
||||
|
||||
DEFAULT_CONFIG_FILE_LOCATION = os.path.join(DEFAULT_CONFIG_ROOT, '{}.config'.format(_name))
|
||||
|
|
Loading…
Reference in New Issue