fix: 修正 Monitor status 就绪退出语义

This commit is contained in:
AgentRun Codex
2026-07-13 06:00:09 +00:00
parent 3dd7ff25cd
commit f1e9375973
2 changed files with 21 additions and 3 deletions
+10 -2
View File
@@ -372,8 +372,11 @@ async function monitorCommand(config: UniDeskConfig, action: string, options: Pl
const script = action === "status" ? monitorStatusScript(pg, target) : monitorResetScript(pg, target);
const capture = await runSshCommandCapture(config, pg.node.route, ["sh"], script);
const parsed = parseJsonOutput(capture.stdout);
const commandOk = action === "status"
? monitorStatusSucceeded(capture.exitCode, parsed)
: capture.exitCode === 0 && parsed?.ok === true;
return {
ok: capture.exitCode === 0 && parsed?.ok === true,
ok: commandOk,
...base,
mutation: action === "reset",
...(action === "reset" ? { confirmed: true } : {}),
@@ -382,6 +385,10 @@ async function monitorCommand(config: UniDeskConfig, action: string, options: Pl
};
}
export function monitorStatusSucceeded(exitCode: number, parsed: Record<string, unknown> | null): boolean {
return exitCode === 0 && parsed?.ok === true && parsed.ready === true;
}
function unsupported(args: string[]): Record<string, unknown> {
return {
ok: false,
@@ -1105,7 +1112,8 @@ fi
empty=false
ready=false
if [ "$schema_ready" = true ] && [ "$business_rows" = "0" ]; then empty=true; ready=true; fi
printf '{"ok":true,"databaseExists":%s,"schemaReady":%s,"empty":%s,"ready":%s,"databaseOid":"%s","schemaVersion":"%s","businessRows":%s,"siblingDatabaseOids":"%s"}\n' "$([ -n "$database_oid" ] && printf true || printf false)" "$schema_ready" "$empty" "$ready" "$database_oid" "$schema_version_observed" "$([ -n "$business_rows" ] && printf '%s' "$business_rows" || printf null)" "$sibling_oids"
printf '{"ok":%s,"databaseExists":%s,"schemaReady":%s,"empty":%s,"ready":%s,"databaseOid":"%s","schemaVersion":"%s","businessRows":%s,"siblingDatabaseOids":"%s"}\n' "$ready" "$([ -n "$database_oid" ] && printf true || printf false)" "$schema_ready" "$empty" "$ready" "$database_oid" "$schema_version_observed" "$([ -n "$business_rows" ] && printf '%s' "$business_rows" || printf null)" "$sibling_oids"
if [ "$ready" != true ]; then exit 1; fi
`;
}