fix: refuse to give the API the mock LLM's port

Both preflights passed for `dev --mock-llm --port 8090`: the port was free, and
then the mock and the API were each handed it. One child could not bind, and the
API was pointed at that port as its model server while trying to listen on it.
This commit is contained in:
Alex committed 2026-09-17 12:39:41 +01:00
1 parent 9e86dd4e94
commit bb50d0a91d
2 files changed
+20

No files matched your search

+6
View File
@@ -739,6 +739,12 @@ def dev(args, context: Optional[Context] = None) -> int:
f"port {args.port} is already in use, so the API cannot bind it. Stop what is on it "
f"(a previous `docsgpt dev`, or `docsgpt down` for an install), or pass --port."
)
if getattr(args, "mock_llm", False) and args.port == dev_module.MOCK_LLM_PORT:
# Both checks below would pass: the port really is free, and then two children want it.
raise DeployError(
f"port {args.port} is where the mock LLM listens, so the API cannot have it too. "
"Give the API another port with --port."
)
if getattr(args, "mock_llm", False) and not _port_is_free(dev_module.MOCK_LLM_PORT):
# It starts first and the others are pointed at it, so a busy port here would surface as the
# API talking to someone else's server, or as a child exiting once everything else is up.