Repository navigation
feat: sleep mode (stop when empty, start when someone joins) - #3
Merged
Merged
Conversation
… guards against loops
codebyant
marked this pull request as ready for review
December 2, 2026 17:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sleep mode per server, with two independent options the owner sets through a signed
server.update_settings:auto_stop_minutes): the agent pings the server every 30 s and stops it after N minutes with nobody online. An unknown player count never counts as empty.wake_on_join:off,anyone,whitelist): while the server is stopped, the agent answers its port with the start of the Minecraft protocol. The server list shows the cached status (icon, version, mod list) with a "sleeping" MOTD; a login gets a disconnect with the owner's text and starts the server.whitelistonly wakes for names inwhitelist.json(case-insensitive, no online lookup).Protocol
server.update_settingsacceptssleep;server.settings.updatedcarries it.server.status.resultaddssleep,sleeping,sleep_error,last_boot_ms,whitelist_count.server.status.changedadds optionalsleepingandsleep_error.trigger(idle_stop,wake_on_join,wake_limited) andplayer; automatic actions use the agent's own id asaccount.host.info.featuresaddssleep_mode.port_in_use,port_shared,start_failed,wake_limited(3 wakes in 10 minutes stop further wakes for the rest of the window; manual Start still works).Security
AGENTS.mdupdated).src/sleep/inbound-scope.test.tsfails if any other file listens.server-ipof one of the agent's own servers, only while it is stopped andwake_on_joinis on. It speaks handshake, status, ping and login start, nothing else. The only effect of a login is starting that server.JSON.stringify. Client addresses are never logged.<state>/sleep/(0700/0600), out of reach of the server process;whitelist.jsonandserver.propertiesare read withopenBeneathand size limits.beforeStart, which closes the listener before systemd starts the unit.Validation
bun run lint,bun run typecheck,bun run test(703 pass),bun run build,bun run check:lib.v1.2.0-alpha.1for consumers.Manual testing (pending)
End-to-end on a real machine with vanilla and Forge/NeoForge servers through a playit tunnel, before merge. Draft until then.