fix(dev): repair rust stack startup

This commit is contained in:
2026-05-08 17:29:22 +08:00
parent 747ef790ac
commit 3efc646868

View File

@@ -219,45 +219,49 @@ request.on("error", () => process.exit(1));
sync_local_spacetime_install() { sync_local_spacetime_install() {
local root_dir="$1" local root_dir="$1"
# SpacetimeDB standalone 会在 --root-dir 下回调 bin/current/spacetimedb-cli.exe # SpacetimeDB standalone 会在 --root-dir 下回调 bin/current/spacetimedb-cli
# Windows 本地开发使用工程内 root-dir 时,需要把用户级安装目录同步进来。 # 使用工程内 root-dir 时,需要把用户级安装目录同步进来。WSL/Linux 下同样需要,
if [[ "${OSTYPE:-}" != msys* && "${OSTYPE:-}" != cygwin* ]]; then # 否则 spacetime start 会在空 root-dir 内查找 current/spacetimedb-cli 并启动失败。
local target_cli="${root_dir}/bin/current/spacetimedb-cli"
local target_cli_exe="${root_dir}/bin/current/spacetimedb-cli.exe"
if [[ -f "${target_cli}" || -f "${target_cli_exe}" ]]; then
return return
fi fi
local target_cli="${root_dir}/bin/current/spacetimedb-cli.exe" local spacetime_path
if [[ -f "${target_cli}" ]]; then spacetime_path="$(command -v spacetime || true)"
if [[ -z "${spacetime_path}" ]]; then
return return
fi fi
local spacetime_command local spacetime_info
spacetime_command="$(command -v spacetime || true)" spacetime_info="$(spacetime --version 2>/dev/null || true)"
if [[ -z "${spacetime_command}" ]]; then
return local cli_path=""
cli_path="$(printf '%s\n' "${spacetime_info}" | sed -n 's/^spacetime Path: //p' | head -n 1)"
if [[ -z "${cli_path}" || ! -f "${cli_path}" ]]; then
cli_path="${spacetime_path}"
fi fi
local install_dir local version_dir
install_dir="$(cd -- "$(dirname -- "${spacetime_command}")" && pwd)" version_dir="$(cd -- "$(dirname -- "${cli_path}")" && pwd)"
if [[ ! -d "${install_dir}/bin" ]]; then if [[ ! -d "${version_dir}" ]]; then
return return
fi fi
echo "[dev:rust] 同步本机 SpacetimeDB 安装到 ${root_dir}" echo "[dev:rust] 同步本机 SpacetimeDB 安装到 ${root_dir}"
mkdir -p "${root_dir}" mkdir -p "${root_dir}/bin"
cp -a "${install_dir}/bin" "${root_dir}/" cp -a "${version_dir}" "${root_dir}/bin/"
if [[ -f "${install_dir}/spacetime.exe" ]]; then local version_name
cp -f "${install_dir}/spacetime.exe" "${root_dir}/spacetime.exe" version_name="$(basename -- "${version_dir}")"
fi
# Git Bash 复制 Windows junction 时可能不会生成可执行的 current 目录;
# 若 current 缺失,则用最新版本目录复制出一个真实目录,满足 standalone 回调路径。
if [[ ! -f "${target_cli}" ]]; then
local version_dir
version_dir="$(find "${root_dir}/bin" -mindepth 1 -maxdepth 1 -type d ! -name current | sort -V | tail -n 1)"
if [[ -n "${version_dir}" && -f "${version_dir}/spacetimedb-cli.exe" ]]; then
rm -rf "${root_dir}/bin/current" rm -rf "${root_dir}/bin/current"
cp -a "${version_dir}" "${root_dir}/bin/current" ln -s "${version_name}" "${root_dir}/bin/current"
fi
# Windows/Git Bash 安装可能还需要根目录 spacetime.exeWSL/Linux 下通常没有该文件。
local install_root
install_root="$(cd -- "${version_dir}/../.." && pwd)"
if [[ -f "${install_root}/spacetime.exe" ]]; then
cp -f "${install_root}/spacetime.exe" "${root_dir}/spacetime.exe"
fi fi
} }
@@ -311,7 +315,7 @@ SPACETIME_ROOT_DIR="${SERVER_RS_DIR}/.spacetimedb/local"
DATABASE="" DATABASE=""
API_LOG="info,tower_http=info" API_LOG="info,tower_http=info"
SPACETIME_TIMEOUT_SECONDS="60" SPACETIME_TIMEOUT_SECONDS="60"
API_SERVER_TIMEOUT_SECONDS="300" API_SERVER_TIMEOUT_SECONDS="600"
SKIP_SPACETIME=0 SKIP_SPACETIME=0
SKIP_PUBLISH=0 SKIP_PUBLISH=0
PRESERVE_DATABASE=0 PRESERVE_DATABASE=0