fix: wait for frontend auth runtime status
This commit is contained in:
@@ -107,7 +107,7 @@ async function apply(config: UniDeskConfig, options: AuthOptions): Promise<Recor
|
|||||||
}
|
}
|
||||||
const remote = await capture(config, auth.target.route, ["sh"], applyScript(auth, material));
|
const remote = await capture(config, auth.target.route, ["sh"], applyScript(auth, material));
|
||||||
const parsed = parseJsonOutput(remote.stdout);
|
const parsed = parseJsonOutput(remote.stdout);
|
||||||
const runtime = await status(config, { ...options, raw: false });
|
const runtime = await waitForRuntimeStatus(config, options);
|
||||||
return {
|
return {
|
||||||
ok: remote.exitCode === 0 && parsed?.ok === true && runtime.ok === true,
|
ok: remote.exitCode === 0 && parsed?.ok === true && runtime.ok === true,
|
||||||
...base,
|
...base,
|
||||||
@@ -119,6 +119,16 @@ async function apply(config: UniDeskConfig, options: AuthOptions): Promise<Recor
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForRuntimeStatus(config: UniDeskConfig, options: AuthOptions): Promise<Record<string, unknown>> {
|
||||||
|
let latest: Record<string, unknown> | null = null;
|
||||||
|
for (let attempt = 1; attempt <= 12; attempt += 1) {
|
||||||
|
latest = await status(config, { ...options, raw: false });
|
||||||
|
if (latest.ok === true) return latest;
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 5_000));
|
||||||
|
}
|
||||||
|
return latest ?? { ok: false, summary: { ok: false, error: "runtime-status-not-run", valuesPrinted: false } };
|
||||||
|
}
|
||||||
|
|
||||||
async function status(config: UniDeskConfig, options: AuthOptions): Promise<Record<string, unknown>> {
|
async function status(config: UniDeskConfig, options: AuthOptions): Promise<Record<string, unknown>> {
|
||||||
const auth = readRuntimeAuthConfig();
|
const auth = readRuntimeAuthConfig();
|
||||||
const material = readAuthMaterial(auth);
|
const material = readAuthMaterial(auth);
|
||||||
|
|||||||
Reference in New Issue
Block a user