Part of #74. Stack: 1. probe app → 2. hapi serve → 3. module boundaries → 4. pre-commit. Based on the 1/4 branch, so the diff shows only this slice.
Summary
hapi serve [--host 127.0.0.1] [--api-port 8000] [--probe-port 8081]
platform.server.serve([Listener(api), Listener(probes)])
asyncio.run
uvicorn :8000 ┐ same event loop: a wedged loop fails liveness (ADR-0009)
uvicorn :8081 ┘
on SIGINT/SIGTERM -> stop both
on one listener stopping -> stop the other
uvicorn's own per-server signal capture is turned off, because two servers in one process would chain each other's handlers. serve owns signal handling instead. just dev runs hapi serve.
Evidence
Before: no way to run the app. After:tests/test_serve.py starts hapi serve as a real process on free ports:
probes answer on the probe port only :8081/livez -> 200, :8000/livez -> 404 PASSED
sigterm stops both listeners cleanly exit code 0 PASSED
These tests use a subprocess rather than calling the CLI in-process (spec Seam 2), because real ports and signals are the behaviour under test. If a port is already taken, the process exits 3 with a uvicorn traceback rather than hanging.
Merge Danger
Door: two-way
Blast Radius: none
#77 (/readyz + drain) should build on the shared shutdown here. --host defaults to 127.0.0.1; the image will need 0.0.0.0 (or a setting in #75).
Part of #74. Stack: 1. probe app → **2. `hapi serve`** → 3. module boundaries → 4. pre-commit. Based on the 1/4 branch, so the diff shows only this slice.
## Summary
```text
hapi serve [--host 127.0.0.1] [--api-port 8000] [--probe-port 8081]
platform.server.serve([Listener(api), Listener(probes)])
asyncio.run
uvicorn :8000 ┐ same event loop: a wedged loop fails liveness (ADR-0009)
uvicorn :8081 ┘
on SIGINT/SIGTERM -> stop both
on one listener stopping -> stop the other
```
uvicorn's own per-server signal capture is turned off, because two servers in one process would chain each other's handlers. `serve` owns signal handling instead. `just dev` runs `hapi serve`.
## Evidence
- **Before:** no way to run the app.
**After:** `tests/test_serve.py` starts `hapi serve` as a real process on free ports:
```text
probes answer on the probe port only :8081/livez -> 200, :8000/livez -> 404 PASSED
sigterm stops both listeners cleanly exit code 0 PASSED
```
These tests use a subprocess rather than calling the CLI in-process (spec Seam 2), because real ports and signals are the behaviour under test. If a port is already taken, the process exits 3 with a uvicorn traceback rather than hanging.
## Merge Danger
**Door:** two-way
**Blast Radius:** none
#77 (`/readyz` + drain) should build on the shared shutdown here. `--host` defaults to `127.0.0.1`; the image will need `0.0.0.0` (or a setting in #75).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two uvicorn servers, the public API on :8000 and the internal probe
listener on :8081, share one event loop (ADR-0009), so a wedged loop
fails liveness. SIGINT/SIGTERM stops both; if one listener stops or
fails to start, the other stops with it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of #74. Stack: 1. probe app → 2.
hapi serve→ 3. module boundaries → 4. pre-commit. Based on the 1/4 branch, so the diff shows only this slice.Summary
uvicorn's own per-server signal capture is turned off, because two servers in one process would chain each other's handlers.
serveowns signal handling instead.just devrunshapi serve.Evidence
After:
tests/test_serve.pystartshapi serveas a real process on free ports:These tests use a subprocess rather than calling the CLI in-process (spec Seam 2), because real ports and signals are the behaviour under test. If a port is already taken, the process exits 3 with a uvicorn traceback rather than hanging.
Merge Danger
Door: two-way
Blast Radius: none
#77 (
/readyz+ drain) should build on the shared shutdown here.--hostdefaults to127.0.0.1; the image will need0.0.0.0(or a setting in #75).🤖 Generated with Claude Code
hapi serveruns the API and probes in one event loop (#74) 12b634b7e0View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.