This commit is contained in:
Adil Hafeez 2025-09-11 15:55:25 -07:00
parent 32838584cf
commit 093834bb05
No known key found for this signature in database
GPG key ID: 9B18EF7691369645
14 changed files with 623 additions and 48 deletions

View file

@ -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:

View file

@ -44,17 +44,18 @@ def docker_start_archgw_detached(
arch_config_file: str,
logs_path_abs: str,
env: dict,
prompt_gateway_port,
llm_gateway_port,
gateway_ports: list[int],
) -> str:
env_args = [item for key, value in env.items() for item in ["-e", f"{key}={value}"]]
port_mappings = [
f"{prompt_gateway_port}:{prompt_gateway_port}",
f"{llm_gateway_port}:{llm_gateway_port}",
f"{llm_gateway_port+1}:{llm_gateway_port+1}",
f"{12001}:{12001}",
"19901:9901",
]
for port in gateway_ports:
port_mappings.append(f"{port}:{port}")
port_mappings_args = [item for port in port_mappings for item in ("-p", port)]
volume_mappings = [

View file

@ -28,9 +28,9 @@ def get_llm_provider_access_keys(arch_config_file):
access_key_list = []
for llm_provider in arch_config_yaml.get("llm_providers", []):
acess_key = llm_provider.get("access_key")
if acess_key is not None:
access_key_list.append(acess_key)
access_key = llm_provider.get("access_key")
if access_key is not None:
access_key_list.append(access_key)
for prompt_target in arch_config_yaml.get("prompt_targets", []):
for k, v in prompt_target.get("endpoint", {}).get("http_headers", {}).items():
@ -44,6 +44,12 @@ def get_llm_provider_access_keys(arch_config_file):
else:
access_key_list.append(v)
for listener in arch_config_yaml.get("listeners", []):
for llm_provider in listener.get("llm_providers", []):
access_key = llm_provider.get("access_key")
if access_key is not None:
access_key_list.append(access_key)
return access_key_list