fix: 完善部署回滚健康检查
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Browser regression (push) Has been cancelled

This commit is contained in:
que01 committed 2026-10-13 15:05:02 +08:00
1 parent 47a24e0d53
commit d2ca528543
2 files changed
+18 -9

No files matched your search

+14 -5
View File
@@ -91,6 +91,18 @@ async function installAdminService(release) {
run("systemctl", ["--user", "restart", adminServiceName]);
}
async function waitForAdminHealth() {
const url = "http://127.0.0.1:" + (process.env.ADMIN_STATIC_PORT ?? "3010") + "/admin/";
for (let attempt = 0; attempt < 20; attempt++) {
try {
const response = await fetch(url, { signal: AbortSignal.timeout(2000) });
if (response.ok) return;
} catch {}
await new Promise((resolve) => setTimeout(resolve, 500));
}
throw new Error("Admin static health check failed");
}
function verifyTraefikAdmin() {
const result = spawnSync(
"docker",
@@ -314,11 +326,7 @@ try {
run("pm2", ["startOrRestart", path.join(release, "deploy/ecosystem.config.cjs"), "--update-env"]);
await installAdminService(release);
await waitForHealth();
const staticResponse = await fetch(
"http://127.0.0.1:" + (process.env.ADMIN_STATIC_PORT ?? "3010") + "/admin/",
{ signal: AbortSignal.timeout(5000) },
);
if (!staticResponse.ok) throw new Error("Admin static health check failed");
await waitForAdminHealth();
verifyTraefikAdmin();
await writeTraefikRoute();
routeUpdated = true;
@@ -342,6 +350,7 @@ try {
"--update-env",
]);
await waitForHealth();
await waitForAdminHealth();
console.error(
"application and route rollback completed; database migrations were not reversed",
);