feat: allow the interface on which the server will listen to be configured

Signed-off-by: Gordon Sim <gsim@redhat.com>
This commit is contained in:
Gordon Sim 2025-05-08 14:21:18 +01:00
parent 7aae8fadbf
commit 966b482b2e
36 changed files with 5 additions and 40 deletions

View file

@ -258,9 +258,9 @@ class ServerConfig(BaseModel):
default=None,
description="Authentication configuration for the server",
)
disable_ipv6: bool = Field(
default=False,
description="Disable IPv6 support",
host: str | None = Field(
default=None,
description="The host the server should listen on",
)

View file

@ -358,7 +358,6 @@ def main(args: argparse.Namespace | None = None):
default=int(os.getenv("LLAMA_STACK_PORT", 8321)),
help="Port to listen on",
)
parser.add_argument("--disable-ipv6", action="store_true", help="Whether to disable IPv6 support")
parser.add_argument(
"--env",
action="append",
@ -514,7 +513,7 @@ def main(args: argparse.Namespace | None = None):
else:
logger.info(f"HTTPS enabled with certificates:\n Key: {keyfile}\n Cert: {certfile}")
listen_host = ["::", "0.0.0.0"] if not config.server.disable_ipv6 else "0.0.0.0"
listen_host = config.server.host or ["::", "0.0.0.0"]
logger.info(f"Listening on {listen_host}:{port}")
uvicorn_config = {