Files
soul-yongping/scripts/本地启动.sh

34 lines
1.1 KiB
Bash
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.

#!/bin/bash
# 本地启动:后端 + 前端,前后端接口均在本地
# 用法:./scripts/本地启动.sh 或 bash scripts/本地启动.sh
set -e
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
# 1. 启动 soul-api需先编译 Mac 版go build -o soul-api-mac ./cmd/server
echo "===== 1. 启动 soul-api端口 8080====="
if [ ! -f soul-api/soul-api-mac ]; then
echo "未找到 soul-api-mac正在编译..."
(cd soul-api && go build -o soul-api-mac ./cmd/server)
fi
APP_ENV=development PORT=8080 "$ROOT/soul-api/soul-api-mac" &
API_PID=$!
echo "soul-api 已启动 PID=$API_PID"
sleep 3
# 2. 健康检查
if ! curl -sf http://localhost:8080/health >/dev/null; then
echo "soul-api 启动失败,请检查数据库连接"
kill $API_PID 2>/dev/null || true
exit 1
fi
echo "soul-api 健康检查通过"
# 3. 启动 soul-admin前台Ctrl+C 退出时会一并停止 soul-api
trap "kill $API_PID 2>/dev/null || true" EXIT
echo ""
echo "===== 2. 启动 soul-admin端口 5174====="
echo "访问 http://localhost:5174 默认账号 admin / admin123"
cd soul-admin && pnpm dev