From 824f2f1d0fe01d4858df59de3e8a49a9f9198dfc Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 21 Mar 2017 16:32:32 -0400 Subject: [PATCH 1/8] handle not being able to decode claim cache file --- lbrynet/lbrynet_daemon/Daemon.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 2365f54c0..d106704bb 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -350,9 +350,13 @@ class Daemon(AuthJSONRPCServer): name_cache_filename = os.path.join(self.db_dir, "stream_info_cache.json") if os.path.isfile(name_cache_filename): - with open(name_cache_filename, "r") as name_cache: - self.name_cache = json.loads(name_cache.read()) - log.info("Loaded claim info cache") + with open(name_cache_filename, "r") as name_cache_file: + name_cache = name_cache_file.read() + try: + self.name_cache = json.loads(name_cache) + log.info("Loaded claim info cache") + except ValueError: + log.warning("Unable to load claim info cache") def _check_network_connection(self): self.connected_to_internet = utils.check_connection() From b19e3adadd6fffe1012a5c17cfafd8e938f7aed0 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 21 Mar 2017 16:33:17 -0400 Subject: [PATCH 2/8] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a480363d..d717c3c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ at anytime. * Fixed api help return * Fixed API command descriptor_get * Fixed API command transaction_show - * + * Handle failure to decode claim cache file * ## [0.9.1] - 2017-03-17 From da3ed0756ea468fee2d5643426a8fcf5d30d9d97 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 21 Mar 2017 17:10:51 -0400 Subject: [PATCH 3/8] =?UTF-8?q?Bump=20version:=200.9.1=20=E2=86=92=200.9.2?= =?UTF-8?q?rc1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- CHANGELOG.md | 25 +++++++++++++++++-------- lbrynet/__init__.py | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 45fd93f17..fee940cda 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.1 +current_version = 0.9.2rc1 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)((?P[a-z]+)(?P\d+))? diff --git a/CHANGELOG.md b/CHANGELOG.md index d717c3c01..3a4287894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,23 +9,32 @@ at anytime. ## [Unreleased] ### Added - * Add `wallet_list` command + * * * ### Changed - * Dont add expected payment to wallet when payment rate is 0 + * * * ### Fixed - * Fixed descriptor_get - * Fixed jsonrpc_reflect() - * Fixed api help return - * Fixed API command descriptor_get - * Fixed API command transaction_show - * Handle failure to decode claim cache file * + * + * + +## [0.9.2rc1] - 2017-03-21 +### Added + * Add `wallet_list` command +### Changed + * Dont add expected payment to wallet when payment rate is 0 +### Fixed + * Fixed descriptor_get + * Fixed jsonrpc_reflect() + * Fixed api help return + * Fixed API command descriptor_get + * Fixed API command transaction_show + * Handle failure to decode claim cache file ## [0.9.1] - 2017-03-17 ### Fixed diff --git a/lbrynet/__init__.py b/lbrynet/__init__.py index 3d613ea02..ea853f495 100644 --- a/lbrynet/__init__.py +++ b/lbrynet/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = "0.9.1" +__version__ = "0.9.2rc1" version = tuple(__version__.split('.')) logging.getLogger(__name__).addHandler(logging.NullHandler()) From e8e2a0d353928f01746a275c38faf3cd8f072d28 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 21 Mar 2017 17:12:29 -0400 Subject: [PATCH 4/8] =?UTF-8?q?Bump=20version:=200.9.2rc1=20=E2=86=92=200.?= =?UTF-8?q?9.3rc1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- lbrynet/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fee940cda..58610de6d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.2rc1 +current_version = 0.9.3rc1 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)((?P[a-z]+)(?P\d+))? diff --git a/lbrynet/__init__.py b/lbrynet/__init__.py index ea853f495..2020ca4f2 100644 --- a/lbrynet/__init__.py +++ b/lbrynet/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = "0.9.2rc1" +__version__ = "0.9.3rc1" version = tuple(__version__.split('.')) logging.getLogger(__name__).addHandler(logging.NullHandler()) From 790baea191c2a1f694832b0613570cca6ac49ffa Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 21 Mar 2017 17:24:07 -0400 Subject: [PATCH 5/8] =?UTF-8?q?Revert=20"Bump=20version:=200.9.2rc1=20?= =?UTF-8?q?=E2=86=92=200.9.3rc1"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e8e2a0d353928f01746a275c38faf3cd8f072d28. --- .bumpversion.cfg | 2 +- lbrynet/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 58610de6d..fee940cda 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.3rc1 +current_version = 0.9.2rc1 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)((?P[a-z]+)(?P\d+))? diff --git a/lbrynet/__init__.py b/lbrynet/__init__.py index 2020ca4f2..ea853f495 100644 --- a/lbrynet/__init__.py +++ b/lbrynet/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = "0.9.3rc1" +__version__ = "0.9.2rc1" version = tuple(__version__.split('.')) logging.getLogger(__name__).addHandler(logging.NullHandler()) From 5e6a742bd3f1a976c0f3f26ff6ac57113227abcb Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Wed, 22 Mar 2017 11:16:13 -0400 Subject: [PATCH 6/8] Fix restart procedure in DaemonControl --- CHANGELOG.md | 2 +- lbrynet/lbrynet_daemon/DaemonControl.py | 2 ++ lbrynet/lbrynet_daemon/DaemonServer.py | 13 ++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a4287894..19ddec1e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ at anytime. * ### Fixed - * + * Fix restart procedure in DaemonControl * * diff --git a/lbrynet/lbrynet_daemon/DaemonControl.py b/lbrynet/lbrynet_daemon/DaemonControl.py index 8cc4158da..4dbd24411 100644 --- a/lbrynet/lbrynet_daemon/DaemonControl.py +++ b/lbrynet/lbrynet_daemon/DaemonControl.py @@ -131,9 +131,11 @@ def start_server_and_listen(launchui, use_auth, analytics_manager, max_tries=5): break except Exception as e: log.exception('Failed to startup') + yield daemon_server.stop() analytics_manager.send_server_startup_error(str(e)) tries += 1 else: + log.warn("Exceeded max tries to start up, stopping") reactor.callFromThread(reactor.stop) diff --git a/lbrynet/lbrynet_daemon/DaemonServer.py b/lbrynet/lbrynet_daemon/DaemonServer.py index a6a197da9..1af7045de 100644 --- a/lbrynet/lbrynet_daemon/DaemonServer.py +++ b/lbrynet/lbrynet_daemon/DaemonServer.py @@ -1,6 +1,5 @@ import logging import os -import sys from twisted.web import server, guard from twisted.internet import defer, reactor, error @@ -19,7 +18,9 @@ log = logging.getLogger(__name__) class DaemonServer(object): def __init__(self, analytics_manager=None): + self._api = None self.root = None + self.server_port = None self.analytics_manager = analytics_manager def _setup_server(self, use_auth): @@ -34,11 +35,11 @@ class DaemonServer(object): lbrynet_server.requestFactory = DaemonRequest try: - reactor.listenTCP( + self.server_port = reactor.listenTCP( conf.settings['api_port'], lbrynet_server, interface=conf.settings['api_host']) except error.CannotListenError: log.info('Daemon already running, exiting app') - sys.exit(1) + raise return defer.succeed(True) @@ -47,6 +48,12 @@ class DaemonServer(object): yield self._setup_server(use_auth) yield self._api.setup(launch_ui) + @defer.inlineCallbacks + def stop(self): + if self._api is not None: + yield self._api._shutdown() + if self.server_port is not None: + yield self.server_port.stopListening() def get_site_base(use_auth, root): if use_auth: From 7fac63a37bafe4a8784e738672af129351c1f8e8 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 20 Mar 2017 11:47:03 -0400 Subject: [PATCH 7/8] create download directory if it doesn't exist --- CHANGELOG.md | 1 + lbrynet/lbrynet_daemon/Daemon.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ddec1e1..52737ead6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ at anytime. ### Fixed * Fix restart procedure in DaemonControl * + * Create download directory if it doesn't exist * ## [0.9.2rc1] - 2017-03-21 diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index d106704bb..c57749ea7 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -232,6 +232,8 @@ class Daemon(AuthJSONRPCServer): conf.settings.update(last_version) self.db_dir = conf.settings['data_dir'] self.download_directory = conf.settings['download_directory'] + if not os.path.exists(self.download_directory): + os.mkdir(self.download_directory) self.created_data_dir = False if not os.path.exists(self.db_dir): os.mkdir(self.db_dir) From 2cc2505cfded76539bb6e7734a8ae3dc02b84748 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Tue, 21 Mar 2017 13:06:52 -0400 Subject: [PATCH 8/8] make directories in one place when initializing --- lbrynet/lbrynet_daemon/Daemon.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index c57749ea7..e366251b6 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -232,18 +232,11 @@ class Daemon(AuthJSONRPCServer): conf.settings.update(last_version) self.db_dir = conf.settings['data_dir'] self.download_directory = conf.settings['download_directory'] - if not os.path.exists(self.download_directory): - os.mkdir(self.download_directory) - self.created_data_dir = False - if not os.path.exists(self.db_dir): - os.mkdir(self.db_dir) - self.created_data_dir = True if conf.settings['BLOBFILES_DIR'] == "blobfiles": self.blobfile_dir = os.path.join(self.db_dir, "blobfiles") else: log.info("Using non-default blobfiles directory: %s", conf.settings['BLOBFILES_DIR']) self.blobfile_dir = conf.settings['BLOBFILES_DIR'] - self.run_on_startup = conf.settings['run_on_startup'] self.data_rate = conf.settings['data_rate'] self.max_key_fee = conf.settings['max_key_fee'] @@ -296,7 +289,7 @@ class Daemon(AuthJSONRPCServer): } self.looping_call_manager = LoopingCallManager(calls) self.sd_identifier = StreamDescriptorIdentifier() - self.stream_info_manager = DBEncryptedFileMetadataManager(self.db_dir) + self.stream_info_manager = None self.lbry_file_manager = None @defer.inlineCallbacks @@ -601,7 +594,10 @@ class Daemon(AuthJSONRPCServer): old_revision = 1 self.startup_status = STARTUP_STAGES[1] log.info("Loading databases") - if self.created_data_dir: + if not os.path.exists(self.download_directory): + os.mkdir(self.download_directory) + if not os.path.exists(self.db_dir): + os.mkdir(self.db_dir) self._write_db_revision_file(self.current_db_revision) log.debug("Created the db revision file: %s", self.db_revision_file) if not os.path.exists(self.blobfile_dir): @@ -642,6 +638,7 @@ class Daemon(AuthJSONRPCServer): def _setup_lbry_file_manager(self): log.info('Starting to setup up file manager') self.startup_status = STARTUP_STAGES[3] + self.stream_info_manager = DBEncryptedFileMetadataManager(self.db_dir) yield self.stream_info_manager.setup() self.lbry_file_manager = EncryptedFileManager( self.session,