Skip to main content
set_start_cmd() configures a command that starts during template build before snapshotting. Readiness probes tell Nullspace when that command is ready, then sandboxes created from the template restore the snapshotted running state instead of rerunning the command. Create-time Sandbox.create(envs=...) values are not visible to the template start command. Use set_runtime_envs() for runtime defaults that should be present in launched sandboxes. For warm pools, treat the template start command and readiness probe as the complete service boot contract. A pooled sandbox may restore an already-ready VM, so service startup must not depend on create-time envs, volume mounts, cwd overrides, desktop settings, or per-create networking options.

Start command

from nullspace import Template, wait_for_port

builder = (
    Template.from_python_image("3.12")
    .copy("./server.py", "/workspace/server.py")
    .set_workdir("/workspace")
    .set_start_cmd("python server.py", readiness=wait_for_port(8080))
)

Readiness helpers

from nullspace import wait_for_file, wait_for_process, wait_for_timeout, wait_for_url

wait_for_file("/tmp/ready")
wait_for_process("python")
wait_for_timeout(5_000)
wait_for_url("http://127.0.0.1:8080/health")
wait_for_url() is an in-guest local HTTP readiness probe. It accepts only http:// URLs on localhost, 127.0.0.1, or 0.0.0.0, requires an explicit port, and rejects query strings, fragments, and embedded credentials. Concept: Create. API reference: buildTemplate, getTemplateBuildStatus.