fix: support ts backend core cli probes

This commit is contained in:
Codex
2026-05-18 16:20:11 +00:00
parent 803a695d0a
commit 29dab8fab2
6 changed files with 95 additions and 20 deletions
+11 -1
View File
@@ -400,7 +400,17 @@ async function probe(url: string): Promise<unknown> {
}
function dockerExecJson(container: string, path: string): unknown {
const result = runCommand(["docker", "exec", container, "backend-core", "--fetch-json", `http://127.0.0.1:8080${path}`], repoRoot);
const url = `http://127.0.0.1:8080${path}`;
const script = [
"set -euo pipefail",
"if command -v backend-core >/dev/null 2>&1; then",
` exec backend-core --fetch-json ${shellQuote(url)}`,
"fi",
`url=${shellQuote(url)}`,
"export url",
"bun -e 'const url=process.env.url; fetch(url).then(async r=>{const text=await r.text(); console.log(JSON.stringify({ok:r.ok,status:r.status,body:text?JSON.parse(text):null})); process.exit(r.ok?0:1);}).catch(e=>{console.error(e); process.exit(1)})'",
].join("\n");
const result = runCommand(["docker", "exec", container, "sh", "-lc", script], repoRoot);
if (result.exitCode !== 0) {
return { ok: false, exitCode: result.exitCode, stdout: result.stdout.slice(-1200), stderr: result.stderr.slice(-1200) };
}