Files
Genarrative/server-rs/scripts/dev.sh
kdletters cbc27bad4a
Some checks failed
CI / verify (push) Has been cancelled
init with react+axum+spacetimedb
2026-04-26 18:06:23 +08:00

42 lines
1.3 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
用法:
./server-rs/scripts/dev.sh
GENARRATIVE_API_HOST=0.0.0.0 GENARRATIVE_API_PORT=3100 ./server-rs/scripts/dev.sh
说明:
1. 为 Rust `api-server` 注入本地开发默认环境变量
2. 使用 `cargo run -p api-server` 启动 Axum 服务
3. 当前只覆盖 `api-server` 本地开发链路,不包含 SpacetimeDB
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
SERVER_RS_DIR="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
if [[ ! -f "${SERVER_RS_DIR}/Cargo.toml" ]]; then
echo "[server-rs:dev] 未找到 ${SERVER_RS_DIR}/Cargo.toml无法启动本地开发脚本。" >&2
exit 1
fi
export GENARRATIVE_API_HOST="${GENARRATIVE_API_HOST:-127.0.0.1}"
export GENARRATIVE_API_PORT="${GENARRATIVE_API_PORT:-3100}"
export GENARRATIVE_API_LOG="${GENARRATIVE_API_LOG:-info,tower_http=info}"
echo "[server-rs:dev] 工作目录: ${SERVER_RS_DIR}"
echo "[server-rs:dev] GENARRATIVE_API_HOST=${GENARRATIVE_API_HOST}"
echo "[server-rs:dev] GENARRATIVE_API_PORT=${GENARRATIVE_API_PORT}"
echo "[server-rs:dev] GENARRATIVE_API_LOG=${GENARRATIVE_API_LOG}"
cd "${SERVER_RS_DIR}"
cargo run -p api-server --manifest-path "${SERVER_RS_DIR}/Cargo.toml"