- Each session’s background jobs, the ones
cmd &starts, and each job’s output. - The processes the workspace runs, which
pslists. - Which instance of the workspace runs them, and when it was last seen.
The group key is
store.execution. A job’s output is a stream other
processes follow, so disk is refused here, and a disk store keeps its
jobs in memory.
In code, SqlWorkspaceStateStore keeps them in a SQL database, SQLite or
Postgres, in two tables it makes on first use, so every process on the
database lists the same jobs, lines and processes, and a restart on it keeps
them. A reader following a job on another process there sees new output
within a quarter of a second.
On Redis
- YAML
- Python
- TypeScript
Several instances of one workspace
Every process that builds the workspace under the same id on one Redis is an instance of it, on one machine or several, behind a load balancer or as replicas of one agent.- YAML
- Python
- TypeScript
- Servers
workspace.yaml
workspace.json holds {"id": "agent", "config": {...}}
with the same config on each. Then:
- One instance runs the workspace’s lines at a time: the first to run one.
Any other is refused with an error naming that instance, which a server
answers with
409, until it stops, deletes or closes the workspace. - If it goes away without doing so, the workspace is free 30 seconds after it was last seen. The next instance to run a line reports the jobs it left as ended with status 129 and stops the programs they left running.
- A server keeps its id under its state root, so a restarted server runs its workspaces again at once.
- Sessions and symlinks are shared, since the whole store is on Redis.
processes: workspace widens that to every session’s.
Shell describes the details.