Update healthcheck.py
This commit is contained in:
@ -7,12 +7,17 @@ import requests
|
|||||||
|
|
||||||
|
|
||||||
def healthcheck():
|
def healthcheck():
|
||||||
"""Check if the website is up."""
|
"""Check if the website is up.
|
||||||
|
|
||||||
|
sys.exit(0): success - the container is healthy and ready for use.
|
||||||
|
sys.exit(1): unhealthy - the container is not working correctly."""
|
||||||
|
# TODO: We should check more than just that the website is up.
|
||||||
try:
|
try:
|
||||||
r = requests.get("http://localhost:5000")
|
r = requests.get("http://localhost:5000")
|
||||||
if r.ok:
|
if r.ok:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"ERROR: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user