fix(media): relays release their live-channel claims on shutdown
LiveRelay.stop() fired the claim releases and forgot them, and nothing closed the shared backend's Postgres pool: on a redeploy the process could exit first, leaving the other instances to follow a dead relay until the claim went stale (30 s). stop() is now async and resolves once the releases are written; MediaService.stop() passes it through; the container awaits it and closes the backend on SIGTERM, and `media serve` gained SIGINT/SIGTERM handling that does the same and closes open sockets so publishers and viewers reconnect elsewhere. Verified: a test that a stopped relay's claim is gone at once; a real `media serve --s3 --pg --advertise` with a live publisher: SIGTERM → exit in ~0.4 s, its shade_live_publishers row 1 → 0, the publisher reconnecting. Suites green (media 101, storage-postgres 20, server 55, cli 15). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,10 @@ New package **`@shade/media`** — see `docs/media.md`.
|
||||
of a channel published elsewhere follows the relay that has the publisher,
|
||||
verifying every frame against the pin, and viewers follow a publisher that
|
||||
moves. Viewers get a `state` message when a channel goes live or quiet.
|
||||
`LiveRelay.stop()` / `MediaService.stop()` now resolve once the relay's
|
||||
claims are released; the container and `media serve` (SIGINT/SIGTERM) wait
|
||||
for it and close the Postgres pool, so a redeploy does not leave other
|
||||
instances pointing at a relay that is gone.
|
||||
- **Library.** `media put` records each upload and its grant in
|
||||
`$XDG_CONFIG_HOME/shade/media-library.jsonl` (0600, append-only); `media
|
||||
ls` shows names, `media link <name|id>` prints a link again. Grants now
|
||||
|
||||
Reference in New Issue
Block a user