Run a command and wait for its result
Starts the command and answers when it has ended (200) or when wait_seconds are up (202 with the command's address). A command that has ended by the time the wait is up is read to its end and answered 200: a 202 is always a command that is still running. Waiting keeps the sandbox from going to sleep by itself; if it is put to sleep while this call waits, the call waits on, and when wait_seconds are up it answers 202 from what the node noted of the command as the sandbox went to sleep, without waking it. The command belongs to the sandbox, not to this request: it runs on when the caller goes away. With an Idempotency-Key, the same key and body again finds the command the first request started and answers from it, with Idempotent-Replayed: true; the same key with another body is 409 idempotency_key_reused.
As a stream (text/event-stream): its events are start, stdout, stderr, gap, exit and error: Event streams and terminals.
Takes exec, or a token of the sandbox with exec.
https://api.glac.ai/v1/sandboxes/{id}/runỦy quyền
Tham số đường dẫn
Tham số header
Thân yêu cầuJSONbắt buộc
- wait_for_readeroptionalboolean
Have the command wait for whoever reads this call's answer, instead of running ahead: once 2 MiB of its output are still to be read it writes no more, as on a full pipe, until they are taken. A stream then carries all of the output, however much there is and however slowly it is read, and never a
gap. Without it a command never waits, and a reader that falls behind what the sandbox keeps (16 MiB) is told what it missed. When the reader has gone the command waits 10 seconds for another and then runs on. A sandbox made before the node knew this field pays no attention to it.default: false
Returns
200
The command has ended: its result as JSON; or, as an event stream, the command from its first byte to its end.
string202
Still running when wait_seconds were up: not a result. status is running, and stdout and stderr hold what the command had written by then. Ask the address in Location (with wait_seconds) for the result.
400
The request is not one this call takes. invalid_json: the body is not a JSON object; unknown_field: the body has a field this call does not take; unknown_parameter: the query has a parameter this call does not take; invalid_field: a field or query parameter has the wrong type or is out of range; missing_command: no command; invalid_env: env has a name or a value an environment cannot hold; no_such_user: user is not a user of the sandbox; terminal_needs_exec: tty was given; invalid_idempotency_key: Idempotency-Key is empty or over 255 characters.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
401
missing_api_key, invalid_api_key, expired_api_key, invalid_token.
403
The credential may not do this. token_scope: the sandbox token lacks the scope. spend_limit_reached: the sandbox is frozen because a spend limit was reached; it sleeps, with its data, until the limit is raised.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
404
Something the request names does not exist. sandbox_not_found: no such sandbox.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
409
The state of something stands in the way. command_lost: the command went away while the call waited for it; sandbox_moved: the sandbox was moved to another node while the call waited, and the command goes on there (to, epoch, offset, and exec_id, the command's id): wait for it there through the control plane with GET …/exec/{exec_id}?wait_seconds=, or make the same call again with the same Idempotency-Key (without one it starts the command a second time); sandbox_failed: the sandbox is failed; idempotency_key_reused: the key was used with another body.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.
default
Any other failure, in the same shape. internal (500): the node failed; the message says no more, and the node's log has the reason under the request's id. unavailable (503, retryable): no_capacity, every network slot of the node is in use; memory_full, a machine the call has to start (made, woken, booted from its disk, resumed, rolled back, built) does not fit in the host's memory beside what the machines that run on it are promised, and nothing paused or idle could be put to sleep to make room for it (memory of the node); drive_full, the call would have a template built and the node's data drive has no room for one (drive of the node); unavailable, the node is shutting down, the sandbox was still starting after 10 minutes, or it did not answer, or it is being moved to this node (with Retry-After: 1); fenced, the node's lease fences the sandbox (Node.lease). moved (409): the sandbox was moved to another node, which to names.
- exec_idoptionalstring
With
sandbox_movedofPOST …/run: the id of the command the call started and waited for, which goes on where the sandbox went: wait for it there through the control plane withGET …/exec/{exec_id}?wait_seconds=once the move is over. The same call made again starts the command a second time, unless it comes with the same Idempotency-Key.