Running your code
Private workers
A private worker runs Bok Joy tasks on a machine you own, for data that must stay on your network or hardware you already pay for. It only makes outgoing requests to the control plane.
On this page
How a private worker works#
A worker is a durable-compute agent process. It asks the control plane for work, runs each attempt in a Docker container sized to the task, and reports the result. It only makes outgoing requests: nothing needs to reach into your network.
- It serves the
privatepool.private-firstruns prefer it, andprivate-onlyruns run nowhere else. See Placement. - It holds a worker token, which opens only the worker routes. It never sees the database or the operator token, and refuses to start if either is in its environment.
- It runs attempts only within the slots, CPU and memory you register.
Register a worker#
Registering needs the operator token. The answer holds the worker's token once:
durable-compute workers register --name office-1 \ --pool private --executor docker \ --slots 2 --cpu-millis 4000 --memory-mib 8192 \ --env prod| Flag | Meaning | Default |
|---|---|---|
--slots | Attempts it runs at once | 1 |
--cpu-millis, --memory-mib | The capacity it offers, shared by its slots | 2000 and 2048 |
--env | Only claim runs of this environment. Repeat it for several. | Every environment |
--deployment with --runtime | Only claim runs of one deployment and runtime | Any |
Save the token to a file only you can read, such as worker.token with mode 600.
Run the agent#
On the worker machine, with Docker running and the CLI built:
export DC_API_URL=https://your-control-plane.example.comdurable-compute agent --executor docker --token-file worker.tokenA file keeps the token out of your shell history and process list. DC_WORKER_TOKEN works too. durable-compute workers list shows each worker's liveness and what it holds.
A worker runs a deployment built with deploy from its exact pinned image, so that image must exist on the worker's Docker host. Until it does, the worker hands its runs back and they wait, as below.
When a worker cannot run something#
An attempt the worker cannot start, for example because the pinned image is missing on its host, is deferred: handed back without using an attempt, and retried with backoff from 1 to 60 seconds. If it still cannot start an hour after the first deferral, the run fails.
When a worker is lost#
A worker renews a short lease on every attempt it runs. If it stops answering, Bok Joy holds its attempts rather than guess:
- The attempts are quarantined. Their capacity stays reserved.
- When the agent restarts, it proves its containers are gone, and only then are the runs retried.
- If the worker never comes back, an operator revokes it and releases its attempts.
durable-compute workers revoke <worker id> --reason "host retired"durable-compute workers release <worker id> --confirm-terminated --reason "host destroyed"Each release is recorded with its reason and who released it: --released-by, else DC_OPERATOR, else your account's user name.
Bok Joy never starts a second copy of an attempt that might still be running.
Drain a worker#
durable-compute workers drain <worker id>The worker stops claiming, finishes the attempts it holds, and the agent exits. Draining is one-way: register again to bring the machine back.
Trusted native workers#
A worker can also run handlers directly on its host, without Docker: register it with --executor native-trusted and start the agent with --executor native. Native execution enforces no CPU, memory or network limits, and cannot run deployments whose dependencies live in images. Use it only for code you trust on a machine set aside for it.