fix: cancel in-progress deploy on new webhook trigger

When a webhook-triggered deploy starts for an app that already has a deploy
in progress, the new deploy now cancels the existing one via context
cancellation, waits for the lock to be released, and then starts the new
deploy.

Changes:
- Add per-app context cancellation (appCancels sync.Map) to deploy.Service
- Deploy() creates a cancellable context and registers it for the app
- Add CancelAppDeploy() method to cancel an in-progress deploy
- Add ErrDeployCancelled sentinel error for cancelled deploys
- Handle context cancellation in build and deploy phases, marking
  deployments as failed with a clear cancellation message
- Webhook triggerDeployment() now cancels in-progress deploys and retries
  until the lock is released (up to 30 attempts with 2s delay)

fixes #38
This commit is contained in:
user
2026-02-15 22:13:20 -08:00
parent 07ac71974c
commit 16640ef88e
4 changed files with 244 additions and 3 deletions

View File

@@ -345,10 +345,12 @@ func (h *Handlers) HandleAppDeploy() http.HandlerFunc {
}
}(deployCtx, application)
redirectURL := "/apps/" + application.ID + "/deployments"
http.Redirect(
writer,
request,
"/apps/"+application.ID+"/deployments",
redirectURL,
http.StatusSeeOther,
)
}