mirror of
https://github.com/katanemo/plano.git
synced 2026-06-23 15:38:07 +02:00
fix more
This commit is contained in:
parent
32838584cf
commit
093834bb05
14 changed files with 623 additions and 48 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import subprocess
|
||||
import os
|
||||
import time
|
||||
|
|
@ -25,7 +26,7 @@ from cli.docker_cli import (
|
|||
log = getLogger(__name__)
|
||||
|
||||
|
||||
def _get_gateway_ports(arch_config_file: str) -> tuple:
|
||||
def _get_gateway_ports(arch_config_file: str) -> list[int]:
|
||||
PROMPT_GATEWAY_DEFAULT_PORT = 10000
|
||||
LLM_GATEWAY_DEFAULT_PORT = 12000
|
||||
|
||||
|
|
@ -34,18 +35,13 @@ def _get_gateway_ports(arch_config_file: str) -> tuple:
|
|||
with open(arch_config_file) as f:
|
||||
arch_config_dict = yaml.safe_load(f)
|
||||
|
||||
prompt_gateway_port = (
|
||||
arch_config_dict.get("listeners", {})
|
||||
.get("ingress_traffic", {})
|
||||
.get("port", PROMPT_GATEWAY_DEFAULT_PORT)
|
||||
)
|
||||
llm_gateway_port = (
|
||||
arch_config_dict.get("listeners", {})
|
||||
.get("egress_traffic", {})
|
||||
.get("port", LLM_GATEWAY_DEFAULT_PORT)
|
||||
)
|
||||
print("arch config dict json string: ", json.dumps(arch_config_dict))
|
||||
|
||||
return prompt_gateway_port, llm_gateway_port
|
||||
all_ports = [
|
||||
listener.get("port") for listener in arch_config_dict.get("listeners", [])
|
||||
]
|
||||
|
||||
return all_ports
|
||||
|
||||
|
||||
def start_arch(arch_config_file, env, log_timeout=120, foreground=False):
|
||||
|
|
@ -67,14 +63,13 @@ def start_arch(arch_config_file, env, log_timeout=120, foreground=False):
|
|||
docker_stop_container(ARCHGW_DOCKER_NAME)
|
||||
docker_remove_container(ARCHGW_DOCKER_NAME)
|
||||
|
||||
prompt_gateway_port, llm_gateway_port = _get_gateway_ports(arch_config_file)
|
||||
gateway_ports = _get_gateway_ports(arch_config_file)
|
||||
|
||||
return_code, _, archgw_stderr = docker_start_archgw_detached(
|
||||
arch_config_file,
|
||||
os.path.expanduser("~/archgw_logs"),
|
||||
env,
|
||||
prompt_gateway_port,
|
||||
llm_gateway_port,
|
||||
gateway_ports,
|
||||
)
|
||||
if return_code != 0:
|
||||
log.info("Failed to start arch gateway: " + str(return_code))
|
||||
|
|
@ -83,13 +78,17 @@ def start_arch(arch_config_file, env, log_timeout=120, foreground=False):
|
|||
|
||||
start_time = time.time()
|
||||
while True:
|
||||
prompt_gateway_health_check_status = health_check_endpoint(
|
||||
f"http://localhost:{prompt_gateway_port}/healthz"
|
||||
)
|
||||
|
||||
llm_gateway_health_check_status = health_check_endpoint(
|
||||
f"http://localhost:{llm_gateway_port}/healthz"
|
||||
)
|
||||
all_listeners_healthy = True
|
||||
for port in gateway_ports:
|
||||
log.info(f"Checking health endpoint on port {port}")
|
||||
health_check_status = health_check_endpoint(
|
||||
f"http://localhost:{port}/healthz"
|
||||
)
|
||||
if health_check_status:
|
||||
log.info(f"Gateway on port {port} is healthy!")
|
||||
else:
|
||||
all_listeners_healthy = False
|
||||
log.info(f"Gateway on port {port} is not healthy yet.")
|
||||
|
||||
archgw_status = docker_container_status(ARCHGW_DOCKER_NAME)
|
||||
current_time = time.time()
|
||||
|
|
@ -106,7 +105,7 @@ def start_arch(arch_config_file, env, log_timeout=120, foreground=False):
|
|||
stream_gateway_logs(follow=False)
|
||||
sys.exit(1)
|
||||
|
||||
if prompt_gateway_health_check_status or llm_gateway_health_check_status:
|
||||
if all_listeners_healthy:
|
||||
log.info("archgw is running and is healthy!")
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue