fix: cancel in-progress deploy when webhook triggers new deploy (closes #38)

When a webhook-triggered deploy starts for an app that already has a deploy
in progress, the existing deploy is now cancelled via context cancellation
before the new deploy begins. This prevents silently lost webhook deploys.

Changes:
- Add per-app active deploy tracking with cancel func and done channel
- Deploy() accepts cancelExisting param: true for webhook, false for manual
- Cancelled deployments are marked with new 'cancelled' status
- Add ErrDeployCancelled sentinel error
- Add DeploymentStatusCancelled model constant
- Add comprehensive tests for cancellation mechanics
This commit is contained in:
2026-02-15 22:12:03 -08:00
parent 9a284d40fd
commit 3f499163a7
6 changed files with 275 additions and 20 deletions

View File

@@ -314,7 +314,7 @@ func (h *Handlers) HandleAppDeploy() http.HandlerFunc {
deployCtx := context.WithoutCancel(request.Context())
go func(ctx context.Context, appToDeploy *models.App) {
deployErr := h.deploy.Deploy(ctx, appToDeploy, nil)
deployErr := h.deploy.Deploy(ctx, appToDeploy, nil, false)
if deployErr != nil {
h.log.Error(
"deployment failed",