Idle pause and wake on request
Set idle_timeout_seconds and the sandbox is paused when nothing has used it for that long. Its memory and processes are kept, and it is billed for storage only while it sleeps. The next request that needs it wakes it: the request waits while the sandbox resumes, then goes through. Off by default. The least is 30 seconds.
# Pause after 5 idle minutes. The next request wakes it.
curl https://api.groundbox.dev/v1/sandboxes \
-H "Authorization: Bearer $GROUNDBOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"idle_timeout_seconds": 300}'
# Change it, or turn it off with null.
curl -X PATCH https://api.groundbox.dev/v1/sandboxes/sbx_... \
-H "Authorization: Bearer $GROUNDBOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"idle_timeout_seconds": 60, "idle_cpu_percent": 20}'
# Pause by hand, and let the next request wake it.
curl -X POST https://api.groundbox.dev/v1/sandboxes/sbx_.../pause \
-H "Authorization: Bearer $GROUNDBOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"wake_on_request": true}'What counts as activity:
- A command, an exec stream, a file call, a desktop action, a save point or an update.
- A connection that is still open: a running command, a terminal, a desktop view.
- A command started through the API that is still running, also after its caller disconnected.
- Preview traffic, and a preview connection that is still open.
A command counts for as long as it runs. To let a sandbox sleep while a server stays up in it, start the server so that the command returns: nohup npm run dev > /tmp/dev.log 2>&1 &. The server is paused with the rest and goes on when the sandbox wakes.
CPU use inside the sandbox does not count. To keep a background job running, set idle_cpu_percent: the sandbox is then not idle while it uses more than that share of one core. Reading the sandbox (GET /v1/sandboxes/{id}, its usage) is not activity and does not wake it.
What wakes it:
- A sandbox paused by its idle timeout wakes on the next command, exec stream, file call, desktop action or fork, and on a request to one of its previews. Set
wake_on_request: falseto keep it paused until you resume it. - A sandbox you paused yourself stays paused until you resume it. Pause with
wake_on_request: trueto have the next request wake it instead. - The sandbox shows which it is:
pause_reasonisidleormanual, andwakes_on_requestsays whether a request will wake it.
A wake is a resume. It needs credit and room under your sandbox limit, and answers with the same errors when it has neither. The timeout (timeout_minutes) still applies: it counts from the last start or wake, so a sandbox that never goes idle stops at its timeout, and each wake starts it again. After a start or a wake the sandbox stays up for at least 60 seconds. A sandbox left paused for a long time is deleted, however it was paused.
An idle pause needs what a pause needs. A sandbox with volumes cannot be paused, so idle_timeout_seconds is refused for it. A fork keeps its source's idle pause; the copies of a fork with count do not, and can be given one with an update. When your team already keeps as many paused sandboxes as it may, an idle sandbox stays up.