From 7d1815d6c9add209fb56741756fba9480485a0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=8B=A5AI?= Date: Fri, 26 Jun 2026 19:05:14 +0800 Subject: [PATCH] fix codex remote hub bootstrap --- scripts/ensure-hub.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/ensure-hub.sh b/scripts/ensure-hub.sh index 774ddf3..7f7f71c 100755 --- a/scripts/ensure-hub.sh +++ b/scripts/ensure-hub.sh @@ -3,6 +3,7 @@ set -eo pipefail INSTALL="$(cd "$(dirname "$0")" && pwd)" PORT="${PCHAT_HTTP_PORT:-13458}" +HUB_HOST="${PCHAT_HUB_HOST:-127.0.0.1}" LOG="$INSTALL/logs/hub.log" NODE="${PCHAT_NODE:-$(command -v node 2>/dev/null || true)}" [[ -z "$NODE" ]] && NODE="/usr/local/opt/node@22/bin/node" @@ -15,11 +16,17 @@ if [[ ! -x "$NODE" ]]; then fi hub_health() { - curl -sf -m 2 "http://127.0.0.1:${PORT}/api/health" >/dev/null 2>&1 + curl -sf -m 2 "http://${HUB_HOST}:${PORT}/api/health" >/dev/null 2>&1 } start_hub() { if hub_health; then return 0; fi + if [[ "$HUB_HOST" != "127.0.0.1" && "$HUB_HOST" != "localhost" ]]; then + echo "[ensure-hub] remote hub not ready: http://${HUB_HOST}:${PORT}; fallback to local :${PORT}" >> "$LOG" + HUB_HOST="127.0.0.1" + export PCHAT_HUB_HOST="$HUB_HOST" + hub_health && return 0 + fi echo "[ensure-hub] starting hub on :${PORT}" >> "$LOG" nohup "$NODE" "$INSTALL/hub.js" >> "$INSTALL/logs/hub.stdout.log" 2>&1 & local i=0 @@ -32,7 +39,7 @@ start_hub() { } if ! start_hub; then - echo "[ensure-hub] FATAL: Hub not ready on 127.0.0.1:${PORT} (waited ~12s). Run: bash 卡若AI/.../Cursor持久对话/脚本/sync-runtime.sh" >&2 + echo "[ensure-hub] FATAL: Hub not ready on ${HUB_HOST}:${PORT} (waited ~12s). Run: bash 卡若AI/.../Cursor持久对话/脚本/sync-runtime.sh" >&2 exit 1 fi