diff --git a/ray_on_golem/provider/node_provider.py b/ray_on_golem/provider/node_provider.py index d58aede8..b4182fe7 100644 --- a/ray_on_golem/provider/node_provider.py +++ b/ray_on_golem/provider/node_provider.py @@ -212,20 +212,25 @@ def _start_webserver( cli_logger.print("Starting webserver done") return else: - cli_logger.abort( - "Starting webserver failed!\nShowing last 50 lines from `{}`:\n{}", - LOGGING_DEBUG_PATH, - "".join(LOGGING_DEBUG_PATH.open("r").readlines()[-50:]), - ) + with LOGGING_DEBUG_PATH.open("r") as file: + cli_logger.abort( + "Starting webserver failed!\nShowing last 50 lines from `{}`:\n{}", + LOGGING_DEBUG_PATH, + "".join(file.readlines()[-50:]), + ) cli_logger.print( "Webserver is not yet running, waiting additional `{}` seconds...", check_seconds, ) - cli_logger.abort( - "Starting webserver failed! Deadline of `{}` reached.", RAY_ON_GOLEM_START_DEADLINE - ) + with LOGGING_DEBUG_PATH.open("r") as file: + cli_logger.abort( + "Starting webserver failed! Deadline of `{}` reached.\nShowing last 50 lines from `{}`:\n{}", + RAY_ON_GOLEM_START_DEADLINE, + LOGGING_DEBUG_PATH, + "".join(file.readlines()[-50:]), + ) @staticmethod def _stop_webserver(ray_on_golem_client: RayOnGolemClient) -> None: diff --git a/ray_on_golem/server/services/yagna.py b/ray_on_golem/server/services/yagna.py index c42c56f8..2656330c 100644 --- a/ray_on_golem/server/services/yagna.py +++ b/ray_on_golem/server/services/yagna.py @@ -100,11 +100,12 @@ async def _run_yagna(self) -> None: logger.info("Starting Yagna done") return else: - logger.error( - "Starting Yagna failed!\nShowing last 50 lines from `%s`:\n%s", - LOGGING_YAGNA_PATH, - "".join(LOGGING_YAGNA_PATH.open("r").readlines()[-50:]), - ) + with LOGGING_YAGNA_PATH.open("r") as file: + logger.error( + "Starting Yagna failed!\nShowing last 50 lines from `%s`:\n%s", + LOGGING_YAGNA_PATH, + "".join(file.readlines()[-50:]), + ) raise YagnaServiceError("Starting Yagna failed!") logger.info( @@ -112,12 +113,13 @@ async def _run_yagna(self) -> None: check_seconds, ) - logger.error( - "Starting Yagna failed! Deadline of `%s` reached.\nShowing last 50 lines from `%s`:\n%s", - YAGNA_START_DEADLINE, - LOGGING_YAGNA_PATH, - "".join(LOGGING_YAGNA_PATH.open("r").readlines()[-50:]), - ) + with LOGGING_YAGNA_PATH.open("r") as file: + logger.error( + "Starting Yagna failed! Deadline of `%s` reached.\nShowing last 50 lines from `%s`:\n%s", + YAGNA_START_DEADLINE, + LOGGING_YAGNA_PATH, + "".join(file.readlines()[-50:]), + ) raise YagnaServiceError("Starting Yagna failed!") async def _on_yagna_early_exit(self) -> None: