fix: run.sh 改为启动 Go 后端 + dashboard stats 格式对齐前端
- run.sh start_backend 改为编译+运行 Go 二进制 - DashboardStats handler 返回前端期望的字段格式 - build/test 命令适配 Go 工具链 - 前端验证: 登录/仪表盘/工单列表/查询页面正常
This commit is contained in:
1 parent
ca308e277d
commit
26148d0ca7
2 files changed
+54
-42
No files matched your search
@@ -74,31 +74,21 @@ start_backend() {
|
||||
return
|
||||
fi
|
||||
|
||||
log "启动后端..."
|
||||
log "启动后端 (Go/Gin)..."
|
||||
|
||||
cd "$SCRIPT_DIR/backend"
|
||||
if [ ! -d "venv" ]; then
|
||||
log "创建 Python 虚拟环境..."
|
||||
python3 -m venv venv
|
||||
fi
|
||||
source venv/bin/activate
|
||||
|
||||
if [ ! -f "venv/lib/python*/site-packages/fastapi/__init__.py" ] 2>/dev/null; then
|
||||
log "安装后端依赖..."
|
||||
pip install -r requirements.txt -q 2>&1 | tail -3
|
||||
fi
|
||||
# 始终重新编译(开发阶段)
|
||||
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||
go build -o sql-platform ./cmd/server/
|
||||
|
||||
# 数据库迁移
|
||||
venv/bin/alembic upgrade head 2>/dev/null || true
|
||||
|
||||
nohup venv/bin/python -m uvicorn app.main:app \
|
||||
--host 0.0.0.0 --port 9000 --reload \
|
||||
nohup ./sql-platform \
|
||||
> "$LOG_DIR/backend.log" 2>&1 &
|
||||
echo $! > "$BACKEND_PID_FILE"
|
||||
|
||||
# 等待后端就绪
|
||||
for i in $(seq 1 15); do
|
||||
if curl -s http://localhost:9000/docs > /dev/null 2>&1; then
|
||||
if curl -s http://localhost:9000/health > /dev/null 2>&1; then
|
||||
ok "后端已启动 → http://localhost:9000 (PID: $(cat $BACKEND_PID_FILE))"
|
||||
return
|
||||
fi
|
||||
@@ -155,7 +145,8 @@ show_status() {
|
||||
|
||||
echo ""
|
||||
echo " API 文档: http://localhost:9000/docs"
|
||||
echo " 默认账号: admin / 123456"
|
||||
echo " 后端引擎: Go/Gin v0.3.1"
|
||||
echo " 默认账号: admin / admin123"
|
||||
echo " 日志目录: $LOG_DIR/"
|
||||
echo ""
|
||||
}
|
||||
@@ -207,10 +198,11 @@ case "${1:-start}" in
|
||||
|
||||
build)
|
||||
log "=== 构建生产版本 ==="
|
||||
cd "$SCRIPT_DIR/backend" && source venv/bin/activate
|
||||
log "构建后端..."
|
||||
pip install -r requirements.txt -q
|
||||
ok "后端依赖已安装"
|
||||
cd "$SCRIPT_DIR/backend"
|
||||
log "编译 Go 后端..."
|
||||
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||
go build -o sql-platform ./cmd/server/
|
||||
ok "后端编译完成 → backend/sql-platform"
|
||||
|
||||
cd "$SCRIPT_DIR/frontend"
|
||||
log "构建前端..."
|
||||
@@ -220,8 +212,9 @@ case "${1:-start}" in
|
||||
|
||||
test|t)
|
||||
log "=== 运行测试 ==="
|
||||
cd "$SCRIPT_DIR/backend" && source venv/bin/activate
|
||||
python -m pytest tests/ -v --tb=short "$@"
|
||||
cd "$SCRIPT_DIR/backend"
|
||||
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||
go test ./... -v "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
Reference in new issue
Block a user