Run a command
A command’s exit code becomes the result of the call, so your script can tell whether the command worked. The CLI exits with the same code, and the TypeScript SDK throwsCommandExitError when the
code is not zero.
Set the directory, environment, and timeout
By default a command starts in the home directory,/data/home, and is stopped after 60 seconds.
You can set another directory, add environment variables for this one command, and set a longer
timeout for a build or a test run, up to 600 seconds. A command that runs past its timeout is killed
and exits with code 124.
Stream output as it is written
By default the output arrives all at once when the command ends. You can stream it instead, which lets you watch a build or a test run while it happens. Streamed output also has no size cap, so use streaming for a command that prints a lot.Send input to a command
When a command reads from standard input, you can pipe data into it from your computer, such as a SQL file for a database client. The CLI takes up to 5 GiB this way, binary data included.Run a long command in the background
A background command is detached from your terminal and has no time limit, so use it for a dev server, a long build, or an agent run. The command returns a job ID at once, and you use that ID to follow the job or end it later.Follow, wait for, and stop a job
When you do not have a job’s ID at hand, list the machine’s jobs. The list shows each job’s ID and whether the job is running or has exited.wait exits with code 124 and leaves the job running.
TERM to
everything that the job started.
Run one command in a new machine
instabox run creates a machine, runs the command in it, and deletes the machine afterwards, also
when the command fails or you press Ctrl-C. Use it for a CI job or a one-off script, where you want
a clean machine each time and nothing left behind. You can add --push to upload a local folder
into the machine before the command runs.
run exits with the command’s exit code, so a CI step fails when the command fails. For a full
pipeline, see CI.
See what ran
The machine keeps a history of the commands that were run throughexec, by anyone, together with
their exit codes. Read it to find out what an agent or a teammate did in the machine. The history
also works while the machine is stopped.
Limits
- A command’s timeout is 60 seconds by default and 600 seconds at most. A background command has no time limit.
- Without streaming, each of stdout and stderr is cut at 1 MiB, and the result’s
truncatedfield says so. - A background job writes stdout and stderr to one log, so the SDK returns both in
stdout. - Over the API,
stdinholds up to 1 MiB of UTF-8 text. For more, or for binary data, write a file first and redirect it into the command. - The history keeps the newest 200 commands, with the first 64 KiB of each output stream.
execexits with code 65 when a command succeeded but its output was binary. Copy files withinstabox pullorinstabox cpinstead.
CLI reference
Every flag of
exec, jobs, run, history, and output.TypeScript commands
commands.run, streaming, and background handles.