Fix dev Rust SpacetimeDB readiness probe
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-30 16:54:18 +08:00
parent 4ef1d27021
commit a560e4e6c1
2 changed files with 17 additions and 6 deletions

View File

@@ -96,12 +96,23 @@ is_spacetime_ready() {
local root_dir="$2"
local output
if ! output="$(spacetime --root-dir="${root_dir}" server ping "${server}" 2>&1)"; then
return 1
if output="$(spacetime --root-dir="${root_dir}" server ping "${server}" 2>&1)" &&
[[ "${output}" == *"Server is online:"* ]]; then
return 0
fi
# SpacetimeDB CLI 2.1.0 在 502 Bad Gateway 时仍可能返回 0不能只依赖退出码。
[[ "${output}" == *"Server is online:"* ]]
# SpacetimeDB CLI 2.1.0 在 Windows 下可能对已监听的 standalone 返回 502
# 直接探测 HTTP 健康端点,避免 npm run dev:rust 卡在“等待 SpacetimeDB 就绪”。
node -e '
const target = new URL("/v1/ping", process.argv[1]);
const client = target.protocol === "https:" ? require("https") : require("http");
const request = client.get(target, { timeout: 1000 }, (response) => {
response.resume();
process.exit(response.statusCode >= 200 && response.statusCode < 300 ? 0 : 1);
});
request.on("timeout", () => request.destroy(new Error("timeout")));
request.on("error", () => process.exit(1));
' "${server}" >/dev/null 2>&1
}
describe_spacetime_root_owner() {