mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5437] [Other] keep_awake: the PC stays awake while the model serves, and while setup runs #5425
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5425
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5437
Author: @mazzyler
Created: 11/6/2026
Status: 🔄 Open
Base:
main← Head:pr/keep-awake📝 Commits (1)
5312684[Other] keepawake: keep_awake holds the PC awake for the serving session and for setup, and prevent_sleep works on Linux and macOS📊 Changes
6 files changed (+284 additions, -24 deletions)
View changed files
📝
apps/host/server/run-config-check.mjs(+2 -1)📝
docs/DETAILS.md(+2 -1)📝
serve/keepawake.py(+153 -16)📝
serve/server.py(+7 -1)📝
serve/test_keepawake.py(+91 -5)📝
setup.py(+29 -0)📄 Description
What this changes
A local model can answer only while the PC is awake. Strata already had an
opt-in key,
prevent_sleep, that held the PC awake while a request wasrunning or waiting. When the model was loaded and idle between requests, the
PC could still go to sleep, and the next request had to wait for it to wake.
On Linux and macOS the key did nothing: the implementation was Windows-only.
This PR:
"keep_awake": true(opt-in, likeprevent_sleep): it holds the samestate for the whole serving session, from the server's start to its exit;
requests coming and going do not drop it;
prevent_sleepwork on Linux and macOS as well:systemd-inhibit --what=sleep:idle --mode=blockchild process;caffeinate -ichild process;requests and is cleared when the server exits;
systemd-inhibit/caffeinate, or without logind/D-Bus,prints one startup line and nothing changes;
setup.pyhold the same state while the first run is preparing themodel: the download and the build can take hours, and a sleeping PC loses
the transfer. The server's own
keep_awaketakes over when it starts.STRATA_KEEP_AWAKE=0turns the setup part off.What stays the same
keep_awake/prevent_sleepthe servercreates no keeper (no thread, no child process) and a request pays nothing.
prevent_sleep's request-scoped behavior areunchanged;
keep_awakeis a new key accepted by the app's run-config check.STRATA_KEEP_AWAKE=0turns that off.Which part of the machine is kept awake
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)stops the system from going to sleep. It deliberately does not set
ES_DISPLAY_REQUIRED: the screen may still turn off on its usual timer.One daemon thread sets and clears the state (it belongs to the thread that
set it).
display may still blank.
prevent_sleep/keep_awakeis a no-op; one startup linesays so (the setup prints nothing).
A failure to set or keep the state is one line in the log; it never fails a
request.
Validation
python -m unittest serve.test_keepawake -v: 13 tests OK on Windows. TheWindows API is mocked; the Linux/macOS keeper starts and stops a real child
process; a session hold survives a request's acquire/release and is cleared
at close; the setup wrapper is covered by an env test.
"keep_awake": trueserved requests normally; its startup line was
keep_awake: the system stays awake (Windows) while the server runs.KNOWN_KEYS,BOOLS).Not run: the
systemd-inhibitpath on a real Linux machine andcaffeinateona Mac (no hardware here). The tests mock the lookup and use a real child process
for the mechanism, so logind/D-Bus behavior on a desktop that actually idles is
unconfirmed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.