Skip to content

Add option for a template ready check #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dobrac
Copy link
Contributor

@dobrac dobrac commented May 29, 2025

Add option for a template ready check. You can specify ready_cmd which will be run until it exits with code 0. Max timeout is 5 minutes. After exit code 0, the template will be marked as ready.

If no ready command is defined, sleep 20 is assumed when the start command is present, and sleep 0 when none is defined. It is also possible to define ready command without any start command. This might be helpful if the filesystem contains self-booted services (e.g. using systemd).

ready_cmd = "echo 'Starting ready check'; sleep 40; echo 'Template is ready'"

This adds possibility to configure the default 20 seconds wait time for a start command.

New documentation can be found at /docs/sandbox-template/ready-cmd.

@dobrac dobrac self-assigned this May 29, 2025
@dobrac dobrac added feature New feature or request cli Improvements or additions to CLI labels May 29, 2025
Copy link

linear bot commented May 29, 2025

Copy link

changeset-bot bot commented May 29, 2025

🦋 Changeset detected

Latest commit: fba3137

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -34,6 +36,9 @@ export function handleE2BRequestError<T>(
case 500:
message = 'internal server error'
break
default:
message = status(code) || 'unknown error'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translate also all other error codes to text, so it doesn't show unknown error

@dobrac dobrac force-pushed the add-option-for-a-health-check-ready-check-e2b-2110 branch from 1f12ca8 to 507a071 Compare June 4, 2025 11:27
@dobrac dobrac marked this pull request as ready for review June 4, 2025 11:27
@ben-fornefeld ben-fornefeld removed their request for review June 4, 2025 11:30
@@ -0,0 +1,22 @@
# Ready Command
The ready command allows you to specify a command that will determine **template sandbox** readiness before creating the snapshot.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readiness before creating the snapshot

Unsure if we explain to the user what snapshot is and when it gets created during the build process. If not, we need to explain it before we start mentioning it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We explain it in the start command. I'll reorganize this as it doesn't make sense to explain it in the start command and not in the sandbox customization (effectively template)

Comment on lines +9 to +18
You can specify the ready command inside the `e2b.toml` in the same directory where you run `e2b template build`.
<CodeGroup isFileName title="e2b.toml" isRunnable={false}>
```toml
# This is a config for E2B sandbox template
template_id = "1wdqsf9le9gk21ztb4mo"
dockerfile = "e2b.Dockerfile"
template_name = "my-agent-sandbox"
ready_cmd = "<your-ready-command>" # $HighlightLine
```
</CodeGroup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the only way to set it through the config file? No option to do it via the CLI (similarly like we have start command option)?

Copy link
Contributor Author

@dobrac dobrac Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done it only through the config file as It didn't make any sense to me to have it configurable through command (as it's bound to the template, not specific build). But, the same applies for the start command too, so I'll add it there for parity. Hopefully this will be removed in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can specify start command
image

Co-authored-by: Vasek Mlejnsky <[email protected]>
@jakubno
Copy link
Member

jakubno commented Jun 5, 2025

Please make sure this is merged only after the new template manager is deployed 🙏 Maybe add a checkbox in the description so it's hard to miss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Improvements or additions to CLI feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants