Skip to content

Commit d9e20af

Browse files
committed
fix: rollback on health check fail
1 parent dfa3a2b commit d9e20af

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

cli/src/commands/deploy-phases.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,19 @@ export async function deployApp(ctx: DeployContext, compose: ParsedCompose): Pro
372372
);
373373
}
374374

375-
if (ctx.config.health_checks?.endpoints?.length) {
376-
await health.checkHTTPEndpoints(ctx.config.health_checks);
377-
}
378375
}
379376

380377
await Nginx.deployNginxTemplates(ctx.cluster.manager.connection, ctx.rendered);
381378

382379
await Hook.runRemote('post-deploy', ctx.cluster.manager.connection, ctx.stackName, ctx.projectRoot, ctx.config, ctx.rendered);
383380
}
384381

382+
export async function runHTTPHealthChecks(ctx: DeployContext): Promise<void> {
383+
if (!ctx.deployApp || !ctx.config.health_checks?.endpoints?.length) return;
384+
const health = new HealthCheck(ctx.cluster.manager.connection, ctx.orchestrator);
385+
await health.checkHTTPEndpoints(ctx.config.health_checks);
386+
}
387+
385388
// ---------------------------------------------------------------------------
386389
// Phase: Audit, metrics, history sync (best-effort)
387390
// ---------------------------------------------------------------------------

cli/src/commands/deploy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { Metrics } from '../services/metrics';
5757
import * as Notification from '../services/notification';
5858

5959
import type { DeployOptions, DeployContext } from './deploy-context';
60-
import { buildAndDistribute, uploadFiles, rollbackUploads, commitUploads, deployAccessories, deployApp, recordHistory } from './deploy-phases';
60+
import { buildAndDistribute, uploadFiles, rollbackUploads, commitUploads, deployAccessories, deployApp, runHTTPHealthChecks, recordHistory } from './deploy-phases';
6161
import type { UploadRollbackPlan } from './deploy-phases';
6262

6363
// ---------------------------------------------------------------------------
@@ -305,6 +305,8 @@ async function execute(ctx: DeployContext): Promise<void> {
305305
await deployApp(ctx, compose);
306306
stackDeployed = ctx.deployApp !== false;
307307

308+
await runHTTPHealthChecks(ctx);
309+
308310
await Promise.all([
309311
ctx.releases.cleanupOldReleases(ctx.stackName, ctx.config),
310312
commitUploads(uploadPlan).catch((e) => printWarning(`Upload commit failed: ${e instanceof Error ? e.message : String(e)}`)),

0 commit comments

Comments
 (0)