Commands
A sandbox runs commands in two ways.
exec runs a command to completion and returns its output.
start returns at once and gives you a Command to control.
Run a command to completion
exec returns the exit code and both output streams:
Code
Set the working directory and the environment
Each command takes its own cwd and env:
Code
Limit how long you wait
timeoutSeconds makes exec return when the time runs out.
This isn't an error: you get the output so far, exitcode is null, and the command keeps running.
Code
Start a long-running command
start doesn't wait.
It returns a Command, and you decide what happens next: write to its standard input, wait for it, read its logs, or stop it.
Code
Stop a command
signal sends a signal by name or by number:
Code
Read the output later
exec deletes the command record when the command finishes.
Pass keep: true to keep it, so another part of your program can read the logs by UUID:
Code
logsRaw reads one stream as bytes, and it takes a byte range.
A negative offset reads from the end of the stream:
Code
sandbox.commands() returns every command that the sandbox knows about, in start order.
Reference
Every method on Command is exactly one request, so you can see what a step costs.
See Command and ExecOptions in the source for the complete list.