mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
fix(api): stop serve cleanly with jobs, streams and remote sessions open
This commit is contained in:
@@ -72,8 +72,8 @@ characters of the API key.
|
||||
## Event stream
|
||||
|
||||
`/api/dashboard/events` sends a `stats` event (the same body as `/status`) on connect and
|
||||
then every 5 seconds, so the connection stays alive and the counters stay current. Between
|
||||
those it sends:
|
||||
then every 5 seconds, so the connection stays alive and the counters stay current. The server
|
||||
closes the connection when it stops. Between those it sends:
|
||||
|
||||
| Event | Data |
|
||||
|-------|------|
|
||||
|
||||
@@ -405,7 +405,7 @@ Every track carries the same fields as a local track: `is_original_lang`, `name`
|
||||
Downloads are asynchronous. `POST /api/download` enqueues a job and returns immediately with a `job_id`. The server runs each job in a background job worker subprocess. You then poll the job endpoints for progress and results.
|
||||
|
||||
!!! info "Job states"
|
||||
A job moves through `queued` → `downloading` → one of the terminal states `completed`, `failed`, or `cancelled`. You can prioritise only queued jobs. You can retry or remove only terminal jobs.
|
||||
A job moves through `queued` → `downloading` → one of the terminal states `completed`, `failed`, or `cancelled`. You can prioritise only queued jobs. You can retry or remove only terminal jobs. When the server stops, it cancels each queued and downloading job and refuses a new job with `SERVER_DRAINING` (409).
|
||||
|
||||
### `POST /api/download`
|
||||
|
||||
|
||||
@@ -617,8 +617,9 @@ Source: `unshackle/core/api/session_store.py`. A singleton you get from
|
||||
`ttl`, in-flight-auth remote sessions expire at `AUTH_INPUT_TIMEOUT`. The removal of
|
||||
a remote session cancels its `InputBridge` and deletes its cache directory (pruning
|
||||
empty parent dirs up to, but not including, the cache root).
|
||||
- The server calls **`cancel_all_bridges()`** on shutdown, to unblock any waiting
|
||||
auth threads.
|
||||
- The server calls **`cancel_all_bridges()`** on shutdown. It ends each open remote session, which
|
||||
unblocks any waiting auth threads, and deletes the cache directory of each one. The server then waits up
|
||||
to 5 seconds for each login that still runs, and deletes its cache directory again when it ends.
|
||||
|
||||
`SessionEntry` fields:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user