The start command allows you to specify a command that will be already running when you spawn your custom sandbox.
This way, you can for example have running servers or seeded databases inside the sandbox that are already fully ready when you spawn the sandbox using the SDK and with zero waiting time for your users during the runtime.The idea behind the start command feature is to lower the wait times for your users and have everything ready for your users when you spawn your sandbox.You can see how it works here.
You can retrieve the start command’s logs using the SDK during runtime.
These logs are the logs from the start command during the build phase.
Copy
Ask AI
import { Sandbox } from '@e2b/code-interpreter'// Spawn your custom sandboxconst sandbox = await Sandbox.create({ id: 'my-agent-sandbox', // If you specify onStderr and onStdout handlers when spawning the sandbox // you will see logs from the start command. onStderr: output => console.log("stderr", output.line), onStdout: output => console.log("stdout", output.line),})// Close sandbox once doneawait sandbox.close()