# deploy.lifecycle

What happens from a deployment request to a new version taking the traffic.

- **Starts when:** You create a deployment, push to the branch, or apply a config
- **Involved:** Dispra API, builders, your service
- **Ends with:** The new version is live, or the old one keeps serving
- **Takes:** 1 to 5 minutes, mostly the build

## Steps

| Step | Who | What | Calls / logs |
|---|---|---|---|
| 1 | Your code | Starts a deployment (or a push to the branch starts one). | calls [Create a deployment](https://docs.dispralabs.com/api/create-a-deployment.md) |
| 2 | Dispra | Queues it and starts building: the image is built from the commit, or the service's image is used as is. | logs [deploy.started](https://docs.dispralabs.com/events/deploy-started.md) |
| 3 | Dispra | Starts the new version next to the old one and runs its health check. |  |
| 4 | Dispra | Health check passes: the new version takes the traffic, the old one stops. | logs [deploy.succeeded](https://docs.dispralabs.com/events/deploy-succeeded.md) |
| 4b | Dispra | Build or health check fails: the old version keeps serving and the deployment ends failed. | logs [deploy.failed](https://docs.dispralabs.com/events/deploy-failed.md) |
| 5 | Your code | Follows it: reads the deployment, or streams the build log until event end. | calls [Stream a deployment's logs](https://docs.dispralabs.com/api/stream-a-deployment-s-logs.md) |
