Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add docs for start command and start command logs [WIP]

Tomas Valenta1cd78211d3f6
diff --git a/apps/docs/src/app/cli/commands/page.mdx b/apps/docs/src/app/cli/commands/page.mdx
index d327ca11f..3545547a2 100644
--- a/apps/docs/src/app/cli/commands/page.mdx
+++ b/apps/docs/src/app/cli/commands/page.mdx
@@ -34,6 +34,9 @@ If there is no `e2b.toml` config a new template will be created.
#### **Options**
<Options>
+ <Option type="-c, --cmd" name="start-command">
+ Speficy the command that should be running when the sandbox starts.
+ </Option>
<Option type="-n, --name" name="template-name">
Specify the name of the sandbox template. You can use the template name to start the sandbox in the SDK. The name must be lowercase and contain only letters, numbers, dashes, and underscores.
</Option>
diff --git a/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx b/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx
new file mode 100644
index 000000000..c31e1ee72
--- /dev/null
+++ b/apps/docs/src/app/sandbox/templates/start-cmd/page.mdx
@@ -0,0 +1,61 @@
+# Start Command
+
+Custom sandboxes allow you to specify a command that will be running when the sandbox is spawned.
+This way you can run a command that will start your app, or run a command that will start a specific process.
+
+
+## How to add a start command
+
+When you are building a sandbox template you can specify the start command by using the `-c` flag:
+
+```bash
+e2b build -c "npm start"
+```
+
+After the sandbox template is built, when you spawn a sandbox the start command will be running if there was no error when it tried to start.
+You can check the logs from the start command by using the SDKs:
+
+
+<CodeGroup title="Check start command logs" isRunnable={false}>
+```js {{ language: 'js' }}
+import { Sandbox } from '@e2b/sdk'
+
+// Spawn your custom sandbox
+const sandbox = await Sandbox.create({ id: 'my-agent-sandbox' })
+
+// Get the stdout and stderr from the start command
+const { stderr, stdout } = await sandbox.startCmd // $HighlightLine
+
+// Close sandbox once done
+await sandbox.close()
+```
+
+```python {{ language: 'python' }}
+from e2b import Sandbox
+
+# Spawn your custom sandbox
+sandbox = Sandbox(id="my-agent-sandbox")
+
+# Get the stdout and stderr from the start command
+stdout = sandbox.start_cmd.stdout # $HighlightLine
+stderr = sandbox.start_cmd.stderr # $HighlightLine
+
+# Close sandbox once done
+sandbox.close()
+```
+</CodeGroup>
+
+
+### Sandbox template config
+
+You can find the current start command in the `e2b.toml`:
+
+<CodeGroup isFileName title="e2b.toml" isRunnable={false}>
+```toml
+# This is a config for E2B sandbox template
+template = "1wdqsf9le9gk21ztb4mo"
+dockerfile = "e2b.Dockerfile"
+name = "my-agent-sandbox"
+start_cmd = "npm start"
+```
+</CodeGroup>