fix(remote): end the remote logins and the pooled remote sessions of a relay when the server stops

This commit is contained in:
imSp4rky
2026-11-30 22:40:38 -07:00
parent 33645b8c96
commit 6e99812e8e
6 changed files with 629 additions and 3 deletions
+7
View File
@@ -643,6 +643,12 @@ Source: `unshackle/core/api/session_store.py`. A singleton you get from
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.
- **Relay.** A server that relays to a `remote_services` server runs **`end_remote_pool()`** after `close_channels()`.
It starts the end of each remote login that waits, and of all idle pooled remote sessions at the same time. A list
call whose login it ends, or whose login comes later, gets `SERVER_DRAINING`. A request in flight finishes first. Every
5 seconds until it has stopped, the server ends each request that opens its lost remote session again. Then
**`close_remote_pool()`** ends the rest and waits up to 5 seconds for each `DELETE` request. The exit of the process
waits for an end that still runs.
- **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.
@@ -817,6 +823,7 @@ saves the returned cache and then stops the tunnel. It does so:
- when a signal or a closed console stops the process, or the cancel of a download job stops its worker
- when the login or any other step of the opening fails, or `create` times out or its answer is cut off
- when a serve that relays for a REST client closes its pooled remote session
- when such a serve stops: each remote login that waits, and all idle pooled remote sessions at the same time
The `DELETE` has a connect and read timeout of 15s each. The client sends it again only once, when a gateway answers with
an error page or asks for the API key in the other header. It does not wait for a rate limit.