fix: wire auto_install_agent_deps into server.py startup (#216)
* fix: wire auto_install_agent_deps into server.py startup; add api/startup.py to ARCHITECTURE.md * fix(tests): kill stale process on test port before server start in conftest Stale servers left by QA harness runs (ports 8792/8793 etc.) or prior test sessions could interfere with conftest starting its own server on TEST_PORT (8788). If the port was already occupied, _wait_for_server hit the wrong server and tests got unexpected 404s/500s, failing non-deterministically — the 'conftest isolation issue' seen this session. Fix: run fuser -k on TEST_PORT before launching the new server process, with a 0.5s sleep for port release. The full suite now runs 571/571 reliably regardless of what other servers were previously active. --------- Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
This commit is contained in:
12
server.py
12
server.py
@@ -12,6 +12,7 @@ from api.auth import check_auth
|
||||
from api.config import HOST, PORT, STATE_DIR, SESSION_DIR, DEFAULT_WORKSPACE
|
||||
from api.helpers import j
|
||||
from api.routes import handle_get, handle_post
|
||||
from api.startup import auto_install_agent_deps
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
@@ -75,7 +76,16 @@ def main() -> None:
|
||||
print(f'[!!] Warning: Hermes agent found but missing modules: {missing}', flush=True)
|
||||
for mod, err in errors.items():
|
||||
print(f' {mod}: {err}', flush=True)
|
||||
print(' Agent features may not work correctly.', flush=True)
|
||||
print(' Attempting to install missing dependencies from agent requirements.txt...', flush=True)
|
||||
auto_install_agent_deps()
|
||||
ok, missing, errors = verify_hermes_imports()
|
||||
if not ok:
|
||||
print(f'[!!] Still missing after install attempt: {missing}', flush=True)
|
||||
for mod, err in errors.items():
|
||||
print(f' {mod}: {err}', flush=True)
|
||||
print(' Agent features may not work correctly.', flush=True)
|
||||
else:
|
||||
print('[ok] Agent dependencies installed successfully.', flush=True)
|
||||
|
||||
STATE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
SESSION_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user