feat: 清理openspec
This commit is contained in:
@@ -647,15 +647,15 @@ launch_generated_run() {
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_generated_run_registration_and_heartbeat() {
|
||||
wait_for_generated_run_heartbeat() {
|
||||
local registration_file="$WORK_DIR/generated-run-registration.response.json"
|
||||
local heartbeat_file="$WORK_DIR/generated-run-heartbeat.response.json"
|
||||
local first_heartbeat=""
|
||||
rm -f "$registration_file" "$heartbeat_file"
|
||||
printf 'waiting for generated Run endpoint %s registration\n' "$GENERATED_RUN_ENDPOINT_ID"
|
||||
printf 'waiting for generated Run heartbeat %s\n' "$GENERATED_RUN_ENDPOINT_ID"
|
||||
for _ in $(seq 1 45); do
|
||||
if [[ -f "$GENERATED_RUN_PID_FILE" ]] && ! kill -0 "$(<"$GENERATED_RUN_PID_FILE")" 2>/dev/null; then
|
||||
printf 'generated Run exited before registration; see %s\n' "$GENERATED_RUN_LOG" >&2
|
||||
printf 'generated Run exited before heartbeat; see %s\n' "$GENERATED_RUN_LOG" >&2
|
||||
return 1
|
||||
fi
|
||||
if json_get "$API_URL/run/endpoints/$GENERATED_RUN_ENDPOINT_ID" "$registration_file" "${AUTH_HEADER[@]}" 2>/dev/null; then
|
||||
@@ -677,13 +677,13 @@ NODE
|
||||
sleep 1
|
||||
done
|
||||
if [[ -z "$first_heartbeat" ]]; then
|
||||
printf 'generated Run endpoint %s did not register with a safe capability report\n' "$GENERATED_RUN_ENDPOINT_ID" >&2
|
||||
printf 'generated Run endpoint %s did not report a safe heartbeat\n' "$GENERATED_RUN_ENDPOINT_ID" >&2
|
||||
[[ -f "$GENERATED_RUN_LOG" ]] && sed -n '1,160p' "$GENERATED_RUN_LOG" >&2
|
||||
return 1
|
||||
fi
|
||||
reject_forbidden_fragments "$registration_file"
|
||||
|
||||
printf 'waiting for generated Run endpoint %s heartbeat\n' "$GENERATED_RUN_ENDPOINT_ID"
|
||||
printf 'waiting for a subsequent generated Run heartbeat %s\n' "$GENERATED_RUN_ENDPOINT_ID"
|
||||
for _ in $(seq 1 45); do
|
||||
if json_get "$API_URL/run/endpoints/$GENERATED_RUN_ENDPOINT_ID" "$heartbeat_file" "${AUTH_HEADER[@]}" 2>/dev/null && node - "$heartbeat_file" "$GENERATED_RUN_ENDPOINT_ID" "$first_heartbeat" <<'NODE'
|
||||
const fs = require("fs");
|
||||
@@ -700,7 +700,7 @@ NODE
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
printf 'generated Run endpoint %s did not report a subsequent heartbeat\n' "$GENERATED_RUN_ENDPOINT_ID" >&2
|
||||
printf 'generated Run %s did not report a subsequent heartbeat\n' "$GENERATED_RUN_ENDPOINT_ID" >&2
|
||||
[[ -f "$GENERATED_RUN_LOG" ]] && sed -n '1,160p' "$GENERATED_RUN_LOG" >&2
|
||||
return 1
|
||||
}
|
||||
@@ -1159,9 +1159,7 @@ JSON
|
||||
|
||||
cat >"$WORK_DIR/log-session-deployment.request.json" <<JSON
|
||||
{
|
||||
"runEndpointId": "$RUN_ENDPOINT_ID",
|
||||
"mode": "existing-server",
|
||||
"profileKey": "run-local",
|
||||
"createInputs": {},
|
||||
"serverRoot": "/srv/local-debug/$LOG_SESSION_SERVER_ID"
|
||||
}
|
||||
@@ -1413,19 +1411,17 @@ reject_forbidden_fragments "$WORK_DIR/server-run-build-job.response.json"
|
||||
reject_forbidden_fragments "$WORK_DIR/server-run-build-artifact.response.json"
|
||||
read_latest_run_download_content "$SERVER_ID" "$WORK_DIR/server-run-download.response.json" "$WORK_DIR/server-run-download-content.bin" "$WORK_DIR/server-run-download-chunks"
|
||||
launch_generated_run "$WORK_DIR/server-run-download-content.bin"
|
||||
wait_for_generated_run_registration_and_heartbeat
|
||||
wait_for_generated_run_heartbeat
|
||||
|
||||
cat >"$WORK_DIR/server-deployment.request.json" <<JSON
|
||||
{
|
||||
"runEndpointId": "$GENERATED_RUN_ENDPOINT_ID",
|
||||
"mode": "custom-command",
|
||||
"profileKey": "run-local",
|
||||
"createInputs": {},
|
||||
"serverRoot": "$RUN_WORKSPACE_ROOT/$SERVER_ID",
|
||||
"startCommand": "/usr/bin/true"
|
||||
}
|
||||
JSON
|
||||
printf 'saving optional deployment settings after generated Run registration\n'
|
||||
printf 'saving optional deployment settings after generated Run heartbeat\n'
|
||||
curl -fsS -X PUT -H 'Content-Type: application/json' "${AUTH_HEADER[@]}" \
|
||||
--data-binary "@$WORK_DIR/server-deployment.request.json" \
|
||||
"$API_URL/server-instances/$SERVER_ID/deployment" >"$WORK_DIR/server-deployment.response.json"
|
||||
|
||||
@@ -188,54 +188,6 @@ wait_for_url() {
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_run_registration() {
|
||||
local attempts="${1:-45}"
|
||||
local run_pid_file="$LOCAL_DEBUG_PID_DIR/run.pid"
|
||||
printf 'waiting for run endpoint %s registration\n' "$RUN_ENDPOINT_ID"
|
||||
for _ in $(seq 1 "$attempts"); do
|
||||
if ! managed_pid_running "$run_pid_file"; then
|
||||
printf 'run exited before endpoint registration; see %s\n' "$LOCAL_DEBUG_LOG_DIR/run.log" >&2
|
||||
return 1
|
||||
fi
|
||||
if run_endpoint_has_recent_heartbeat; then
|
||||
printf 'run endpoint %s is registered\n' "$RUN_ENDPOINT_ID"
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
printf 'run endpoint %s did not register before timeout\n' "$RUN_ENDPOINT_ID" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
run_endpoint_has_recent_heartbeat() {
|
||||
[[ -f "$PLATFORM_METADATA_PATH" ]] || return 1
|
||||
node -e '
|
||||
const fs = require("fs");
|
||||
const metadata = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
||||
const endpointID = process.argv[2];
|
||||
function findEndpoint(value) {
|
||||
if (!value || typeof value !== "object") return null;
|
||||
if ((value.ID || value.id) === endpointID && (value.LastHeartbeatAt || value.lastHeartbeatAt)) return value;
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) {
|
||||
const found = findEndpoint(item);
|
||||
if (found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
for (const item of Object.values(value)) {
|
||||
const found = findEndpoint(item);
|
||||
if (found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const endpoint = findEndpoint(metadata);
|
||||
const heartbeat = endpoint && (endpoint.LastHeartbeatAt || endpoint.lastHeartbeatAt);
|
||||
const ageMilliseconds = heartbeat ? Date.now() - Date.parse(heartbeat) : Number.POSITIVE_INFINITY;
|
||||
process.exit(Number.isFinite(ageMilliseconds) && ageMilliseconds >= 0 && ageMilliseconds < 30000 ? 0 : 1);
|
||||
' "$PLATFORM_METADATA_PATH" "$RUN_ENDPOINT_ID"
|
||||
}
|
||||
|
||||
printf 'local debug root: %s\n' "$LOCAL_DEBUG_ROOT"
|
||||
printf 'platform: %s\n' "$(local_debug_platform_url)"
|
||||
printf 'platform_web: %s\n' "$(local_debug_web_url)"
|
||||
@@ -303,8 +255,6 @@ start_service run "$(dirname "$RUN_BOOTSTRAP_BIN")" env \
|
||||
RUN_RETRY_BACKOFF_MS="$RUN_RETRY_BACKOFF_MS" \
|
||||
"$RUN_BOOTSTRAP_BIN"
|
||||
|
||||
wait_for_run_registration
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Local debug stack requested.
|
||||
|
||||
Reference in New Issue
Block a user