Files
Cyrene_v2/scripts/dev-up.sh
T
Aska 0c93bb4497
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled
docs(deploy): README 全流程本地部署方案 + scripts/dev-up.sh 一键启动(PG→llama.cpp embedding→cyrene),路径固定 ~/apps 与 ~/.models,勿用 /tmp
2026-09-06 11:39:59 +08:00

61 lines
2.5 KiB
Bash
Executable File
Raw 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
# Cyrene v2 本地一键开发启动:PG+pgvector → llama.cpp embedding → 前端 build → cyrene
# 用法:bash scripts/dev-up.sh (在仓库根目录;需 docker + go + node)
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
MODEL_DIR="$HOME/.models"
LLAMA_DIR="$HOME/apps/llama.cpp"
APP_NAME="cyrene"
APP_BIN="$HOME/apps/cyrene/$APP_NAME"
EMB_MODEL="$MODEL_DIR/Qwen3-Embedding-0.6B-Q8_0.gguf"
EMB_PORT=11434
GW_PORT=10080
cd "$REPO"
echo "==> [1/4] PostgreSQL + pgvector (docker)"
if command -v docker >/dev/null 2>&1; then
docker compose -f docker-compose.dev.yml up -d pg || echo " (docker compose up pg 失败,忽略继续——若未用 PG 可跳过)"
else
echo " (未检测到 docker;若用 SQLite 默认可不启动 PG)"
fi
echo "==> [2/4] llama.cpp embedding (Qwen3-Embedding,Vulkan)"
if [ -x "$LLAMA_DIR/llama-server" ] && [ -f "$EMB_MODEL" ]; then
# 已在跑则跳过
if ! curl -s --max-time 2 "http://127.0.0.1:$EMB_PORT/health" >/dev/null 2>&1; then
(cd "$LLAMA_DIR" && nohup ./llama-server -m "$EMB_MODEL" --embedding -ngl 99 --host 127.0.0.1 --port "$EMB_PORT" > "$HOME/cy-emb.log" 2>&1 &)
echo " llama-server 已启动: http://127.0.0.1:$EMB_PORT"
else
echo " llama-server 已在运行 (: $EMB_PORT),跳过"
fi
else
echo " (未找到 $LLAMA_DIR/llama-server 或模型 $EMB_MODEL;跳过。"
echo " llama.cpp 放 ~/apps/llama.cpp,GGUF 放 ~/.models/)"
fi
echo "==> [3/4] 前端构建 (go:embed 需要 dist)"
if [ -d frontend/web ]; then
(cd frontend/web && npm ci >/dev/null 2>&1 && npm run build >/dev/null 2>&1) || echo " (前端 build 跳过/失败——若已存在 dist 可忽略)"
fi
echo "==> [4/4] 构建并启动 cyrene"
if [ ! -f "$APP_BIN" ]; then
mkdir -p "$HOME/apps/cyrene"
echo " go build -> $APP_BIN"
go build -ldflags="-s -w" -trimpath -o "$APP_BIN" ./cmd/cyrene
fi
if ! curl -s --max-time 2 "http://127.0.0.1:$GW_PORT/api/v1/health" >/dev/null 2>&1; then
(cd "$REPO" && nohup "$APP_BIN" > "$HOME/cy.log" 2>&1 &)
echo " cyrene 已启动: http://localhost:$GW_PORT (日志 $HOME/cy.log)"
else
echo " cyrene 已在运行 (: $GW_PORT),跳过"
fi
echo
echo "完成。访问 http://localhost:$GW_PORT (.env 的 PORT 覆盖此值)"
echo " · LLM: .env 的 LLM_PROVIDER / ANTHROPIC_* 或 LLM_*"
echo " · 向量: EMBEDDING_API_URL=http://127.0.0.1:$EMB_PORT/v1/embeddings EMBEDDING_MODEL=Qwen3-Embedding-0.6B"
echo " · 停止: pkill -f llama-server ; pkill -f $APP_NAME"