# Replace deploys By default a server-mode deploy updates the running box in place. Some services cannot restart without an outage, such as an in-memory search index that takes minutes to rebuild. For those, a replace deploy launches a second box, warms it up away from traffic, and only then moves the public address to it: ```typescript compute: { mode: 'server', volumes: { index: { size: 100, mountPath: '/data/index', snapshots: { schedule: 'daily', retention: { count: 7 } } }, uploads: { size: 50, mountPath: '/data/uploads' }, }, deployStrategy: { type: 'replace', warmUp: { command: 'systemctl start search-warm', healthCheck: { path: '/health' }, }, timeoutSeconds: 1800, retainOldForMinutes: 60, volumes: { index: 'from-snapshot', uploads: 'move' }, }, } ``` Available on AWS. Hetzner is not supported yet: the deploy stops and says so. ## What a deploy does 1. Launches a box from the same config, tagged `Role=app-replacement`. Every deploy path targets `Role=app`, so the replacement does not receive a deploy by accident. 2. Restores each `from-snapshot` volume from its newest completed snapshot and mounts it on the replacement. The original keeps serving the old box. 3. Reconciles the owned services on the replacement and ships the release to it through the ordinary deploy path. 4. Warms it up. `warmUp.command` must exit 0, and `warmUp.healthCheck` is polled on the box itself until it answers 2xx or 3xx (port 80 and the first site's domain by default), within `timeoutSeconds`. 5. Moves each `move` volume. Its mount is stopped on the old box, which stops the services that require it. The volume is then detached, attached to the replacement and mounted, and the health check runs again. 6. Moves the Elastic IP to the replacement and swaps the roles: the replacement becomes `Role=app`, the old box `Role=app-standby`. The instance's alarms follow it. Restored volumes take their volume's name, and the originals are renamed `-retired`. If anything fails before step 6, the moved volumes go back to the old box, the services they stopped are started again, and the replacement and its restored volumes are deleted. The old box keeps serving, and the deploy fails, saying why. ## Dry run, rollback and retirement - `cloud deploy --dry-run` lists every step a replace deploy would take. - `cloud deploy:rollback` within `retainOldForMinutes` moves the address (and moved volumes) back to the retained box and terminates the replacement. No release is redeployed. With `--to` or `--only-if-live` it does an ordinary release rollback instead. - After the window, the next deploy terminates the old box. A retired original volume is kept unless it declares `deleteProtection: false`. A deploy made while a previous one is still within its window ends that window first. The record of the last replace deploy is kept in the driver state (`storage/cloud/state/.json`, `replace`).