AI: never cut a request off mid-reply; bound the logs and the stop path

- service.py: the idle stop's settings write now happens under the same lock
  claim() holds, so a request arriving between the idle check and the write
  can no longer have its selection overwritten and its server stopped under it.
- service.py: _reconcile no longer stops or replaces a server with a request
  in flight, however the switch happens (selecting another backend or None,
  changing Strata's model): the old server finishes its request, and the new
  one does not start until the GPU's memory is free again.
- service.py: an "external" server is only used once a poll has proved the
  program behind its port answers as that server; a port held by something
  else now fails the request saying who holds it, instead of forwarding
  prompts to it.
- strata_host.py: the stop watchdog is real -- if server.main never returns
  within 40 s of the stop request it ends the engine processes and exits,
  instead of relying on interrupt_main() alone (The Kurgan's 45 s kill stays
  as the last resort); the never-read stopping event is gone. It rotates its
  logs at startup: the task log keeps one .prev, the newest seven stdout or
  stderr files per start are kept.
- backends.py: StrataBackend.before_start rotates strata-host.log the way
  LlamaBackend does for llama-server.log.
- tests: five new tests (the two draining guards, external verification,
  both rotations). README updated to match.

VRAM-aware start (the review's "port closed != GPU free, check VRAM before
start") stays a capability idea: no setting knows a model's size to check
free VRAM against.
This commit is contained in:
paul committed 2026-12-05 17:13:10 +13:00
1 parent 9036c6e734
commit 8969a57045
5 files changed
+171 -23

No files matched your search

+15 -7
View File
@@ -30,7 +30,8 @@ This does the following:
`-RetireAIServices` stops and disables the **Strata Local Service** and **Qwen4 Local Service**
tasks, so The Kurgan can run whichever server you select. Without that switch, The Kurgan finds
those servers already listening on their ports. It shows them as "running outside The Kurgan"
and monitors them, but it never starts a second copy.
and monitors them, but it never starts a second copy. Requests go to one only once it answers
as the expected server; a port held by some other program is reported, not served.
`uninstall.ps1` removes the task. `uninstall.ps1 -RestoreAIServices` also re-enables and starts
the two LLM service tasks. `-RemovePawnIO` uninstalls PawnIO.
@@ -133,6 +134,9 @@ server it is addressed to. If the other server is running, it is stopped first:
cutting it off.
- Stopping means stopping completely: every process in its job object has ended and its port
has closed. Only then does the other server start.
- A server with a request in flight is never stopped or replaced mid-reply, however the switch
happens: the old server finishes its request first, and the new one doesn't start until the
GPU's memory is free again.
- A request that has to start its server waits for it. A swap takes a few seconds, plus the model's
load time (about 45 s for either model). Give clients a generous timeout.
@@ -162,10 +166,12 @@ Strata's optional API-monitor page (`/api-monitor`) uses absolute paths, so it d
Both start with no model in memory. The model loads on the first request, or when you press
**Load model**. Strata unloads it after 2000 s idle; llama.cpp sleeps after its preset's idle
time. Strata is stopped gracefully through a named event, and gets 45 s to finish. llama.cpp
is ended through its job object. Each server gets the same environment its own service gave it:
Strata runs with `GGML_CUDA_DISABLE_GRAPHS=1`, and llama.cpp runs without it. Both use OpenBLAS's
default threading, not the single-thread pin The Kurgan uses for itself.
time. Strata is stopped gracefully through a named event, and gets 45 s to finish; if the server
somehow never returns from that, it ends its engine processes and exits by itself after 40 s
(The Kurgan's kill stays as the last resort). llama.cpp is ended through its job object. Each
server gets the same environment its own service gave it: Strata runs with
`GGML_CUDA_DISABLE_GRAPHS=1`, and llama.cpp runs without it. Both use OpenBLAS's default
threading, not the single-thread pin The Kurgan uses for itself.
Live progress comes from different places:
@@ -174,8 +180,10 @@ Live progress comes from different places:
Logs:
- `%LOCALAPPDATA%\Kurgan\logs\strata-host.log`, plus Strata's own `D:\AI\Strata\logs\local-service-*.log`
- `%LOCALAPPDATA%\Kurgan\logs\llama-server.log` (the previous run's log is kept as `.prev`)
- `%LOCALAPPDATA%\Kurgan\logs\strata-host.log` and `llama-server.log` (each keeps the previous
run's log as `.prev`)
- Strata's own `D:\AI\Strata\logs\local-service-*.log`: the task log keeps one `.prev`, and the
newest seven stdout/stderr pairs are kept
A server that exits on its own is restarted after 5 seconds. After 5 exits within 5 minutes,
The Kurgan waits 5 minutes before trying again, and the UI shows why.