Spawn Beginner Stable โ
What it is. Spawn launches EC2 instances and manages their full lifecycle. It provisions the spored daemon onto each instance, which then enforces auto-termination, idle detection, DNS, and notifications independently of your laptop.
When to use it. Whenever you want to actually run something โ from a single scratch box to a production-scale sweep. Start with one machine; the same tool scales up when you need it.
First commands:
spawn # interactive wizard (no flags needed)
spawn launch analysis --instance-type m8a.4xlarge --ttl 8h
spawn connect analysis # SSH in
spawn status analysis # state, cost, TTL countdown
spawn terminate analysis # tear it downSpawn vs spored โ what runs where โ
Spawn is the client on your laptop; spored is the agent on the instance. Some actions are immediate API calls from spawn; others happen later because spored re-reads the instance's EC2 tags about once a minute.
Your computer AWS EC2 instance
spawn โโ launch/provision โโโถ spored (reads spawn:* tags every ~1 min)
โโ extend / config โโโถ โโ TTL, idle, completion, cost
โโ stop / hibernate / terminate + notifySo spawn extend changes the deadline immediately (an API/tag write), but an idle-timeout or completion action is enforced by spored on its next check. Full picture: Security, credentials & data flow.
The three tiers of spawn โ
Spawn is far more capable than "launch one instance." Learn it in tiers โ you only need Tier 1 to be productive:
Tier 1 โ One machine Beginner : launch โ connect โ run โ status โ extend โ stop/terminate. Start at Your first instance.
Tier 2 โ Managed workload Automation : add --command, a completion signal, --idle-timeout, --cost-limit, and lifecycle notifications so a job runs and cleans up unattended (Story B in Common Workflows).
Tier 3 โ Parallel & production scale Advanced HPC : job arrays, parameter sweeps, MPI clusters, autoscaling, workflow engines, images/snapshots, and Capacity Blocks. The command reference is the exhaustive map of this tier.
Install โ
brew tap spore-host/tap && brew trust spore-host/tap
brew install spore-host/tap/spawnCore commands โ
spawn / spawn launch โ
Launch an instance. With no arguments, the interactive wizard runs:
spawnWith flags:
spawn launch \
--name my-instance \
--instance-type g5.xlarge \
--region us-east-1 \
--ttl 8hspawn list โ
List your running (or all) instances:
spawn list
spawn list --state all
spawn list --region us-east-1spawn status โ
Detailed status for one instance:
spawn status my-instance
spawn status i-0a1b2c3d4e5f
spawn status my-instance -o json # machine-readable
spawn status my-instance --check-complete # exit 0=complete 1=failed 2=running 3=error--check-complete polls the instance's completion file and exits with a standardized code, so scripts can wait for a workload to finish (v0.36.6+):
| Exit | Meaning |
|---|---|
| 0 | Complete โ completion file present |
| 1 | Failed โ completion file reports a failure status |
| 2 | Running โ completion file not yet present |
| 3 | Error โ instance unreachable or status undeterminable |
# Wait for a workload to finish
while spawn status my-job --check-complete; [ $? -eq 2 ]; do sleep 30; doneJSON output (-o json) has two shapes, depending on the instance state:
- Running instance: spawn asks spored on the instance (over SSH, or SSM when no key resolves) and prints
spored status --output jsonverbatim. Top-level fields includeinstance_id,name,region,spored_version,started_at,elapsed_seconds,compute_seconds,billed_seconds,stopped_seconds,cpu_percent,network_bytes_per_min,disk_bytes_per_min, and these objects:ttl(configured,remaining_seconds,terminate_at),idle(configured,timeout_seconds,is_idle,idle_seconds,action,remaining_seconds),on_complete(action,completion_file,sentinel_present), andcost(omitted when no price is known). - Any other state (stopped, pending, terminated, โฆ): spawn builds the report from EC2 and the instance's tags without reaching the instance. It has
"source": "ec2"and fields such asinstance_id,name,region,instance_type,spot,state,stopped_since,ttl_deadline,ttl_remaining_seconds,ttl_past_due,compute_seconds,compute_cost,storage_costandcumulative_cost.
Check for "source": "ec2" to tell the two apart.
spawn stop / spawn hibernate / spawn start โ
spawn stop my-instance # stop (compute billing pauses; EBS keeps billing)
spawn hibernate my-instance # hibernate to disk (saves RAM state)
spawn start my-instance # start stopped or hibernated instancestop and hibernate preserve EBS volumes. To permanently destroy an instance, use terminate.
spawn terminate โ
Permanently terminate an instance โ destroys the instance and its EBS volumes (unlike stop/hibernate). Irreversible, so it confirms by default:
spawn terminate my-instance # prompts, then terminates
spawn terminate my-instance -y # skip confirmation
spawn terminate --job-array-name workers # terminate a whole job arrayOn a running spawn task run instance, terminate first flushes the task's command.log and a failed completion record (terminal_reasonuser_terminated) to S3 over SSM, as a TTL kill does. The flush is bounded and best-effort: if it fails, the instance is terminated anyway. See Tasks and worker pools.
spawn extend โ
Push an instance's TTL deadline later. The duration is added to the current deadline, not counted from now (if the deadline has already passed, the new one is now plus the duration):
spawn extend my-instance 4h # add 4 hours to the current deadlineextend writes the new deadline to the tags, then has spored reload them, over SSH, or over SSM (spored reload) when the instance has no key or public IP or SSH fails. If no reload reaches spored, the tags are still updated but spored may go on enforcing the old limit, so extend exits non-zero (since v0.136.0; before, it warned and exited 0). For a job array, it exits non-zero when any member wasn't updated or reloaded.
spawn connect โ
Open an interactive SSH session, or run a command and return. The command is wrapped in bash -c on the remote side, so compound operators and background jobs (&) work correctly:
spawn connect my-instance # interactive
spawn connect my-instance -- 'tail -20 /tmp/run.log' # one-shot
spawn connect my-instance -- 'cmd1 && cmd2' # compound
spawn connect my-instance -- 'nohup bash /tmp/run.sh > /tmp/run.log 2>&1 &' # background
spawn connect my-instance -- 'aws s3 cp s3://bucket/run.sh /tmp/ && bash /tmp/run.sh &'When multiple instances share a name, spawn connect prefers the running one. Stopped or hibernated instances are automatically started before connecting โ use --no-start to prevent this.
spawn defaults โ
Manage default launch settings:
spawn defaults set idle-timeout 1h
spawn defaults set active-processes rsession
spawn defaults list
spawn defaults unset active-processesDefaults are stored in ~/.spawn/config.yaml and apply to every launch unless overridden. See Configuration.
spawn notify (experimental) โ
Register instances and users for Slack, Teams, or Discord control. Chat-platform integrations are experimental and not part of 1.0, and the hosted spore-bot is decommissioned, so these commands need a self-hosted spore-bot:
spawn notify workspace add ...
spawn notify register ...
spawn notify enable ...
spawn notify list ...See Slack Setup, Teams Setup or Discord Setup for the full walkthrough.
spawn capacity-block purchase โ
Purchase an EC2 Capacity Block for ML from an offering discovered with truffle capacity-blocks:
# Preview the price and terms (no charge)
spawn capacity-block purchase <offering-id> --instance-type p5.48xlarge \
--count 1 --duration-hours 24 --region us-east-1 --dry-run
# Real purchase โ prompts for three typed confirmations
spawn capacity-block purchase <offering-id> --instance-type p5.48xlarge \
--count 1 --duration-hours 24 --region us-east-1A Capacity Block is billed up front and is non-refundable, so the purchase requires three typed confirmations (the exact price, purchase <offering-id>, and an acknowledgement phrase) and refuses to run non-interactively โ no --yes bypass. Once purchased, launch into it with spawn launch --reservation-id <id> --capacity-block --az <block-az>, or have lagotto launch it automatically at the reserved start time (lagotto launch --at). See Capacity Blocks for ML for the full three-tool flow.
Key concepts โ
TTL โ every instance has an absolute termination deadline: launch_time + TTL. When it fires, the instance terminates. The deadline is stored in a tag at launch and is never reset by stop/wake cycles โ it keeps counting even while the instance is stopped. spawn extend pushes the deadline forward, not from now.
Idle timeout โ spored monitors CPU, network, disk, GPU, sessions, and configured process names. When all signals indicate inactivity for the configured duration, the instance stops (or hibernates with --on-idle hibernate). The idle timer resets every time the instance wakes. On a spawn launch instance, idle timeout never terminates; the TTL, a --cost-limit, and --on-complete terminate do. spawn service instances, pool workers and spawn burst members are the exception: they terminate at their idle timeout.
Spored โ a small daemon that runs on the instance, enforces the TTL deadline, detects idleness, registers DNS, and sends lifecycle notifications. Installed automatically at launch.
Pre-stop hooks โ a shell command that runs before any lifecycle-triggered stop or termination. Use it to save checkpoints, sync output to S3, or notify downstream systems.
Job arrays โ spawn launch --count N launches N identical instances. Each instance gets a set of environment variables so it knows its role:
| Variable | Description |
|---|---|
JOB_ARRAY_ID | Unique array ID (UUID) |
JOB_ARRAY_NAME | Array name (from --job-array-name) |
JOB_ARRAY_SIZE | Total instances in the array |
JOB_ARRAY_INDEX | Zero-based index of this instance (0 โฆ N-1) |
Example โ shard a dataset across 8 instances:
spawn launch data-proc --count 8 --job-array-name data-proc \
--instance-type c6a.xlarge --ttl 2h
# On each instance:
# CHUNK=$((total_chunks / JOB_ARRAY_SIZE))
# START=$((JOB_ARRAY_INDEX * CHUNK))
# process_data --start $START --count $CHUNK--region vs --regions โ spawn uses --region (singular, one value) since a launch targets a single region. truffle uses --regions / -r (plural, comma-separated) since it searches across multiple regions at once. When piping truffle output to spawn, use the single region from truffle's result:
region=$(truffle spot c6a.xlarge --sort-by-price --pick-first | jq -r .region)
spawn launch my-job --instance-type c6a.xlarge --region "$region"TIP
See TTL vs idle timeout for a complete explanation with a worked timeline.
Programmatic access โ
Use spawn from Python scripts, notebooks, or FastAPI backends via the Python SDK:
import spore
# List running instances
instances = spore.spawn.list()
for inst in instances:
print(inst.name, inst.state, inst.ttl)
# Poll status until complete
inst = spore.spawn.status("my-job")
inst.wait("terminated")Or poll spawn status --check-complete and branch on its exit code (works for a single instance and, via spawn sweep status --check-complete, for sweeps):
# Exit 0=complete, 1=failed, 2=running, 3=error
while spawn status my-job --check-complete; [ $? -eq 2 ]; do sleep 30; doneCommon mistakes โ
terminateto "pause" a job. Terminate destroys the EBS volume and its data โ usestop/hibernateto pause. See stop vs hibernate vs terminate.- Expecting
--on-completeto fire for work you start yourself. A--commandsignals completion when it exits, pass or fail (its exit code goes to/tmp/SPAWN_EXITCODE), by writing the--completion-filepath (/tmp/SPAWN_COMPLETEby default). Work you start another way, such as overspawn connect, has to signal it: runspored completeortouch /tmp/SPAWN_COMPLETE. - Restarting a stopped instance whose TTL already passed. The TTL is absolute;
spawn extendfirst if you need more time. --regionvs--regions. spawn takes one--region; truffle takes plural--regions(see above).
Full list: Troubleshooting & common mistakes.
How it connects โ
Truffle tells spawn what to launch; spawn launches it and provisions spored, which enforces the lifecycle from the instance. Lagotto can drive spawn when it's waiting on capacity.