Skip to content

Commit ac086b4

Browse files
committed
improve deprecated health check warning
1 parent 149033a commit ac086b4

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

api/scripts/healthcheck.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33

44
import requests
55

6+
HEALTH_LIVENESS_URL = "http://localhost:8000/health/liveness"
7+
8+
9+
logger = logging.getLogger(__name__)
10+
611

712
def main() -> None:
8-
logging.getLogger(__name__).warning(
9-
"`python scripts/healthcheck.py` is deprecated. "
10-
"Use the `health/liveness` endpoint instead."
13+
logger.warning(
14+
f"This healthcheck, invoked by {' '.join(sys.argv)}, is deprecated. "
15+
f"Use the `{HEALTH_LIVENESS_URL}` endpoint instead."
1116
)
12-
url = "http://localhost:8000/health/liveness"
13-
status = requests.get(url).status_code
17+
status_code = requests.get(HEALTH_LIVENESS_URL).status_code
18+
19+
if status_code != 200:
20+
logger.error(f"Health check failed with status {status_code}")
1421

15-
sys.exit(0 if 200 >= status < 300 else 1)
22+
sys.exit(0 if 200 >= status_code < 300 else 1)
1623

1724

1825
if __name__ == "__main__":

0 commit comments

Comments
 (0)