master #14
@@ -219,45 +219,49 @@ request.on("error", () => process.exit(1));
|
||||
sync_local_spacetime_install() {
|
||||
local root_dir="$1"
|
||||
|
||||
# SpacetimeDB standalone 会在 --root-dir 下回调 bin/current/spacetimedb-cli.exe;
|
||||
# Windows 本地开发使用工程内 root-dir 时,需要把用户级安装目录同步进来。
|
||||
if [[ "${OSTYPE:-}" != msys* && "${OSTYPE:-}" != cygwin* ]]; then
|
||||
# SpacetimeDB standalone 会在 --root-dir 下回调 bin/current/spacetimedb-cli;
|
||||
# 使用工程内 root-dir 时,需要把用户级安装目录同步进来。WSL/Linux 下同样需要,
|
||||
# 否则 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
|
||||
fi
|
||||
|
||||
local target_cli="${root_dir}/bin/current/spacetimedb-cli.exe"
|
||||
if [[ -f "${target_cli}" ]]; then
|
||||
local spacetime_path
|
||||
spacetime_path="$(command -v spacetime || true)"
|
||||
if [[ -z "${spacetime_path}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local spacetime_command
|
||||
spacetime_command="$(command -v spacetime || true)"
|
||||
if [[ -z "${spacetime_command}" ]]; then
|
||||
return
|
||||
local spacetime_info
|
||||
spacetime_info="$(spacetime --version 2>/dev/null || true)"
|
||||
|
||||
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
|
||||
|
||||
local install_dir
|
||||
install_dir="$(cd -- "$(dirname -- "${spacetime_command}")" && pwd)"
|
||||
if [[ ! -d "${install_dir}/bin" ]]; then
|
||||
local version_dir
|
||||
version_dir="$(cd -- "$(dirname -- "${cli_path}")" && pwd)"
|
||||
if [[ ! -d "${version_dir}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "[dev:rust] 同步本机 SpacetimeDB 安装到 ${root_dir}"
|
||||
mkdir -p "${root_dir}"
|
||||
cp -a "${install_dir}/bin" "${root_dir}/"
|
||||
if [[ -f "${install_dir}/spacetime.exe" ]]; then
|
||||
cp -f "${install_dir}/spacetime.exe" "${root_dir}/spacetime.exe"
|
||||
fi
|
||||
mkdir -p "${root_dir}/bin"
|
||||
cp -a "${version_dir}" "${root_dir}/bin/"
|
||||
local version_name
|
||||
version_name="$(basename -- "${version_dir}")"
|
||||
rm -rf "${root_dir}/bin/current"
|
||||
ln -s "${version_name}" "${root_dir}/bin/current"
|
||||
|
||||
# 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"
|
||||
cp -a "${version_dir}" "${root_dir}/bin/current"
|
||||
fi
|
||||
# Windows/Git Bash 安装可能还需要根目录 spacetime.exe;WSL/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
|
||||
}
|
||||
|
||||
@@ -311,7 +315,7 @@ SPACETIME_ROOT_DIR="${SERVER_RS_DIR}/.spacetimedb/local"
|
||||
DATABASE=""
|
||||
API_LOG="info,tower_http=info"
|
||||
SPACETIME_TIMEOUT_SECONDS="60"
|
||||
API_SERVER_TIMEOUT_SECONDS="300"
|
||||
API_SERVER_TIMEOUT_SECONDS="600"
|
||||
SKIP_SPACETIME=0
|
||||
SKIP_PUBLISH=0
|
||||
PRESERVE_DATABASE=0
|
||||
|
||||
Reference in New Issue
Block a user