fix(remote): end remote session work when the server stops, and leave no session cache behind

This commit is contained in:
imSp4rky
2026-11-30 19:21:21 -07:00
parent bafce963d3
commit c41d8ec3cf
6 changed files with 504 additions and 25 deletions
+12 -6
View File
@@ -633,12 +633,18 @@ Source: `unshackle/core/api/session_store.py`. A singleton you get from
- **Removal.** Eviction, expiry and `delete()` end the remote session the same way: they cancel its
`InputBridge`, close its channel, send the `delete` dashboard event, schedule a staged service reload
and delete its cache directory (pruning empty parent dirs up to, but not including, the cache root). A request
that waits for the remote session then answers `SESSION_NOT_FOUND` and starts no service code.
- **`track_login(task)`** keeps each login task of `session/create` until it ends.
- The server calls **`close()`** on shutdown. It ends each open remote session, which
unblocks any waiting auth threads, and deletes the cache directory of each one. It sends no dashboard event
and schedules no reload. It then waits up to 5 seconds for each login that still runs, and stops the sweep.
A login that ends after the shutdown deletes its cache directory again.
that waits for the remote session then answers `SESSION_NOT_FOUND` and starts no service code. So does a request
whose service code waits on the client for a prompt or a CDM call, whatever that code does next. A service thread
that runs can still write to the cache directory, so a task deletes the directory again after the last request.
- **`track_login(task)`** keeps each login task of `session/create`, and each task that deletes a cache directory
again, until it ends.
- **Shutdown.** First, `close_channels()` cancels each `InputBridge` and closes each channel, so no request waits
for a client while the server waits for its requests. Then the server calls **`close()`**. It ends each open
remote session and deletes the cache directory of each one. It sends no dashboard event
and schedules no reload. It then waits up to 5 seconds for each tracked task that still runs, and stops the sweep.
Within that time, a login that ends deletes its cache directory again.
- **Signals.** The first `SIGTERM` starts the shutdown, and the server ignores each later one. A second Ctrl+C forces
the end. On Windows only Ctrl+C starts the shutdown.
`SessionEntry` fields: