From e122c62ef12c2494f318e8220a9d7b76a58c2164 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 26 Jan 2022 12:11:30 +0100 Subject: [PATCH] Fix check-alive task --- tasks.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index 22a9019..2912ef3 100644 --- a/tasks.py +++ b/tasks.py @@ -64,13 +64,17 @@ def deploy(ctx: Context) -> None: @task def check_alive(ctx: Context) -> None: + exception = None for _ in range(5): try: res = requests.get("https://g4b.ovh/admin/") res.raise_for_status() - except requests.exceptions.HTTPError: + print("Server is up & running") + return + except requests.exceptions.HTTPError as e: time.sleep(1) - return + exception = e + raise RuntimeError("Failed to reach the server") from exception @task(pre=[check, build, publish, deploy], post=[check_alive])