Skip to content

Commit

Permalink
improve deprecated health check warning
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Mar 4, 2025
1 parent 1dd094f commit a7cf5ed
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions api/scripts/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@

import requests

HEALTH_LIVENESS_URL = "http://localhost:8000/health/liveness"


logger = logging.getLogger(__name__)


def main() -> None:
logging.getLogger(__name__).warning(
"`python scripts/healthcheck.py` is deprecated. "
"Use the `health/liveness` endpoint instead."
logger.warning(
f"This healthcheck, invoked by {' '.join(sys.argv)}, is deprecated. "
f"Use the `{HEALTH_LIVENESS_URL}` endpoint instead."
)
url = "http://localhost:8000/health/liveness"
status = requests.get(url).status_code
status_code = requests.get(HEALTH_LIVENESS_URL).status_code

if status_code != 200:
logger.error(f"Health check failed with status {status_code}")

sys.exit(0 if 200 >= status < 300 else 1)
sys.exit(0 if 200 >= status_code < 300 else 1)


if __name__ == "__main__":
Expand Down

0 comments on commit a7cf5ed

Please sign in to comment.