Beispiel #1
0
def start_server_and_listen(use_auth, analytics_manager):
    """
    Args:
        use_auth: set to true to enable http authentication
        analytics_manager: to send analytics
    """
    analytics_manager.send_server_startup()
    daemon_server = DaemonServer(analytics_manager)
    try:
        yield daemon_server.start(use_auth)
        analytics_manager.send_server_startup_success()
    except Exception as e:
        log.exception('Failed to start lbrynet-daemon')
        analytics_manager.send_server_startup_error(str(e))
        daemon_server.stop()
Beispiel #2
0
def start_server_and_listen(use_auth, analytics_manager):
    """
    Args:
        use_auth: set to true to enable http authentication
        analytics_manager: to send analytics
    """
    analytics_manager.send_server_startup()
    daemon_server = DaemonServer(analytics_manager)
    try:
        yield daemon_server.start(use_auth)
        analytics_manager.send_server_startup_success()
    except Exception as e:
        log.exception('Failed to start lbrynet-daemon')
        analytics_manager.send_server_startup_error(str(e))
        daemon_server.stop()
Beispiel #3
0
def start_server_and_listen(use_auth, analytics_manager, max_tries=5):
    """The primary entry point for launching the daemon.
    Args:
        use_auth: set to true to enable http authentication
        analytics_manager: to send analytics
    """
    analytics_manager.send_server_startup()
    daemon_server = DaemonServer(analytics_manager)
    try:
        yield daemon_server.start(use_auth)
        analytics_manager.send_server_startup_success()
    except Exception as e:
        log.exception('Failed to startup')
        yield daemon_server.stop()
        analytics_manager.send_server_startup_error(str(e))
        reactor.fireSystemEvent("shutdown")
Beispiel #4
0
def start_server_and_listen(use_auth, analytics_manager, quiet):
    log_support.configure_console()
    logging.getLogger("lbrynet").setLevel(logging.CRITICAL)
    logging.getLogger("lbryum").setLevel(logging.CRITICAL)
    logging.getLogger("requests").setLevel(logging.CRITICAL)

    analytics_manager.send_server_startup()
    daemon_server = DaemonServer(analytics_manager)
    try:
        yield daemon_server.start(use_auth)
        analytics_manager.send_server_startup_success()
        if not quiet:
            print "Started lbrynet-daemon!"
        defer.returnValue(True)
    except Exception as e:
        log.exception('Failed to start lbrynet-daemon')
        analytics_manager.send_server_startup_error(str(e))
        daemon_server.stop()
        raise
Beispiel #5
0
class Lbry:

    def __init__(self, verbose=False):
        self.verbose = verbose
        self.data_path = None
        self.download_path = None
        self.server = LbryDaemonServer(MocAnalyticsManager())

    @property
    def daemon(self):
        assert self.server._daemon is not None, "Lbry daemon has not been started."
        return self.server._daemon

    @property
    def session(self):
        return self.daemon.session

    @property
    def wallet(self):
        return self.session.wallet

    @defer.inlineCallbacks
    def start(self):
        self.data_path = tempfile.mkdtemp()

        wallet_directory = os.path.join(self.data_path, 'lbryum')
        download_directory = os.path.join(self.data_path, 'Downloads')

        os.mkdir(wallet_directory)
        os.mkdir(download_directory)

        with open(os.path.join(wallet_directory, 'regtest_headers'), 'w'):
            pass

        lbry_conf.settings = None
        lbry_conf.initialize_settings(load_conf_file=False)
        lbry_conf.settings['data_dir'] = os.path.join(self.data_path, 'lbrynet')
        lbry_conf.settings['lbryum_wallet_dir'] = wallet_directory
        lbry_conf.settings['download_directory'] = download_directory
        lbry_conf.settings['use_upnp'] = False
        lbry_conf.settings['blockchain_name'] = 'lbrycrd_regtest'
        lbry_conf.settings['lbryum_servers'] = [('localhost', 50001)]
        lbry_conf.settings.load_conf_file_settings()

        yield self.server.start(use_auth=False)

    @defer.inlineCallbacks
    def stop(self):
        yield self.daemon.exchange_rate_manager.stop()
        yield self.daemon._shutdown()
        yield self.server.server_port.stopListening()
Beispiel #6
0
 def __init__(self, verbose=False):
     self.verbose = verbose
     self.data_path = None
     self.download_path = None
     self.server = LbryDaemonServer(MocAnalyticsManager())