fix codex remote hub bootstrap
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user