Files
memind/scripts/run-memind-portal-candidate.sh
john 046704816f
Memind CI / Test, build, and release guards (push) Successful in 1m41s
fix: use container MCP path in portal canary
2026-07-26 22:34:58 +08:00

50 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
STABLE_ROOT="${MEMIND_CANARY_STABLE_ROOT:-/Users/john/Project/Memind}"
if [[ ! -d "${STABLE_ROOT}" || ! -f "${STABLE_ROOT}/.env" ]]; then
echo "[portal-candidate] stable persistent root is unavailable: ${STABLE_ROOT}" >&2
exit 1
fi
cd "${ROOT}"
set -a
# shellcheck disable=SC1091
source "${STABLE_ROOT}/.env"
set +a
export NODE_ENV=production
export MEMIND_PORTAL_H5_ROOT="${STABLE_ROOT}"
export MEMIND_RUNTIME_ROLE=candidate
export MEMIND_CANARY_PASSIVE_RUNTIME=1
export MEMIND_RUNTIME_BUILD_ID="${MEMIND_CANARY_RELEASE_ID:?MEMIND_CANARY_RELEASE_ID is required}"
export MEMIND_AGENT_RUN_WORKER_ID="portal-candidate-${MEMIND_RUNTIME_BUILD_ID}"
export MEMIND_WORKSPACE_MAINTENANCE=0
export H5_REMINDER_WORKER_ENABLED=0
export H5_PORT="${MEMIND_CANARY_CANDIDATE_PORT:-18081}"
export H5_HOST=127.0.0.1
export H5_PUBLIC_BASE_URL="${H5_PUBLIC_BASE_URL:-https://m.tkmind.cn}"
export TKMIND_API_TARGETS="${MEMIND_CANARY_GOOSED_URL:-https://127.0.0.1:18015}"
export TKMIND_API_TARGET="${MEMIND_CANARY_GOOSED_URL:-https://127.0.0.1:18015}"
# Extensions are spawned inside goosed-canary, where the candidate artifact is
# mounted at /opt/portal. Never inherit host-only MCP paths from the stable .env.
export GOOSED_MCP_NODE_PATH=/usr/local/bin/node
export GOOSED_MCP_SERVER_PATH=/opt/portal/mindspace-sandbox-mcp.mjs
unset TKMIND_API_TARGET_1
NODE_BIN="${NODE_BIN:-/opt/homebrew/opt/node@24/bin/node}"
if [[ ! -x "${NODE_BIN}" ]]; then
NODE_BIN="$(command -v node)"
fi
port="${H5_PORT}"
if lsof -tiTCP:"${port}" -sTCP:LISTEN >/dev/null 2>&1; then
echo "[portal-candidate] port ${port} is already in use; refusing to replace it" >&2
exit 1
fi
exec "${NODE_BIN}" "${ROOT}/server.mjs"