bug: fix check for server ready when using 0.0.0.0 as host (#9002)
* Fix check for server ready when using 0.0.0.0 as host * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix: add noqa comment to health check host assignment for clarity --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
c38df91841
commit
7a02842730
2 changed files with 26 additions and 153 deletions
|
|
@ -147,11 +147,15 @@ def set_var_for_macos_issue() -> None:
|
|||
|
||||
def wait_for_server_ready(host, port, protocol) -> None:
|
||||
"""Wait for the server to become ready by polling the health endpoint."""
|
||||
# Use localhost for health check when host is 0.0.0.0 (bind to all interfaces)
|
||||
health_check_host = "localhost" if host == "0.0.0.0" else host # noqa: S104
|
||||
|
||||
status_code = 0
|
||||
while status_code != httpx.codes.OK:
|
||||
try:
|
||||
status_code = httpx.get(
|
||||
f"{protocol}://{host}:{port}/health", verify=host not in ("127.0.0.1", "localhost")
|
||||
f"{protocol}://{health_check_host}:{port}/health",
|
||||
verify=health_check_host not in ("127.0.0.1", "localhost"),
|
||||
).status_code
|
||||
except HTTPError:
|
||||
time.sleep(1)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue