Skip to main content
set_start_cmd() is a microVM template-build setting. The command runs during template build before snapshotting. Sandboxes created from the template restore that snapshotted running state instead of rerunning the command at sandbox create time. Create-time environment variables passed to Sandbox.create(envs=...) are not visible to the template start command. Use set_runtime_envs() for defaults that should be present in sandboxes launched from the template.

Start command

from nullspace import Template, wait_for_port

builder = (
    Template()
    .from_python_image("3.12")
    .pip_install(["fastapi", "uvicorn"])
    .copy("./app.py", "/workspace/app.py")
    .set_workdir("/workspace")
    .set_start_cmd(
        "uvicorn app:app --host 0.0.0.0 --port 8080",
        readiness=wait_for_port(8080),
    )
)

Readiness helpers

from nullspace import (
    wait_for_file,
    wait_for_port,
    wait_for_process,
    wait_for_timeout,
    wait_for_url,
)

wait_for_port(8080)
wait_for_url("http://127.0.0.1:8080/health")
wait_for_file("/tmp/ready")
wait_for_process("server")
wait_for_timeout(5_000)
wait_for_url() is an in-guest local HTTP probe. It only accepts http:// URLs on localhost, 127.0.0.1, or 0.0.0.0; the URL must include an explicit port and cannot include query strings, fragments, or embedded credentials.

Warm Pools

Template warm pools use this same start-ready snapshot as their startup contract. Put service boot inputs that must exist before pooling in template runtime defaults with set_runtime_envs(). Create-time envs, volume mounts, cwd overrides, desktop settings, custom networking, non-destroy timeout policy, and auto-resume are not visible to the prewarmed service boot path. Use Template Warm Pools for the checkout modes and fallback behavior.

Ready command

builder = builder.set_ready_cmd("curl -fsS http://127.0.0.1:8080/health")