From 1f2946bd3fde14a712c9a95bccd43458e2d7fd62 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 24 Feb 2022 21:14:44 +0100 Subject: [PATCH] Fix check-alive task --- tasks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tasks.py b/tasks.py index b9b59cd..6fc4891 100644 --- a/tasks.py +++ b/tasks.py @@ -77,13 +77,17 @@ def deploy(ctx: Context) -> None: @task def check_alive(ctx: Context) -> None: + exception = None for _ in range(5): try: res = requests.get("https://gabnotes.org") res.raise_for_status() - except requests.exceptions.HTTPError: - time.sleep(1) - return + print("Server is up & running") + return + except requests.exceptions.HTTPError as e: + time.sleep(2) + exception = e + raise RuntimeError("Failed to reach the server") from exception @task(pre=[check, build, publish, deploy], post=[check_alive])