# How servers get their bundles

> How a deployed version reaches a server - bundles stored by their hash, a desired state per server in the network's Durable Object, the connector syncing files, and the Minekube plugin swapping them in.

The Minekube API keeps what each server should run. A server gets that desired state every time it connects, so it never has to catch up on what happened while it was away.

1. **Bundles are stored by their SHA-256** on Cloudflare R2, readable only by the network's servers. Versions and deployments live in the network's Durable Object.
2. **The server's connector keeps a signed control channel** to that object. When it connects, and whenever a deployment changes, the object works out the bundles for the server's labels and platform and sends their names and hashes.
3. **The connector compares the hashes** with the files in `plugins/Minekube/games/`, downloads only what is missing or different, checks each hash and writes the file atomically. It removes bundles it wrote that no deployment gives it any more. It leaves files it did not write, such as what `mk dev` installed, alone. A bundle built for another [platform version](https://minekube.com/games/concepts/platform-version) than the server runs is installed too, with a warning in the server's log that names both versions.
4. **The Minekube plugin sees the new file**, loads it on a thread of its own and swaps it in on the server thread, as on the dev server. A bundle that fails to load never replaces the running one.

The bundles stay on the server's disk, so a server starts with its last version even when the Minekube API is unreachable.

## Why desired state

- **A server that was offline catches up by itself.** It gets the current state when it connects, not a list of events it missed.
- **A new server needs no setup.** Its labels decide what it runs from the moment it joins.
- **A rollback is the same operation as a deploy.** It changes the desired state, and every server converges to it.

## Related

- [Connector, relay and API](https://minekube.com/guide/networks/connectivity): the control channel and the Minekube API, in Connect.
- [Live swap](https://minekube.com/games/local-development/live-swap): what the plugin does with a new bundle.
