Fix check-alive task

This commit is contained in:
Gabriel Augendre 2022-02-24 21:14:44 +01:00
parent 327f8d8cd0
commit 1f2946bd3f

View file

@ -77,13 +77,17 @@ def deploy(ctx: Context) -> None:
@task @task
def check_alive(ctx: Context) -> None: def check_alive(ctx: Context) -> None:
exception = None
for _ in range(5): for _ in range(5):
try: try:
res = requests.get("https://gabnotes.org") res = requests.get("https://gabnotes.org")
res.raise_for_status() res.raise_for_status()
except requests.exceptions.HTTPError: print("Server is up & running")
time.sleep(1)
return 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]) @task(pre=[check, build, publish, deploy], post=[check_alive])