chore: 建立本地稳定开发基线

This commit is contained in:
NathanAlex7
2026-09-10 11:23:55 +08:00
parent 299a3eb803
commit 549fd069be
6 changed files with 188 additions and 89 deletions
+29 -18
View File
@@ -1,24 +1,35 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -Eeuo pipefail
echo "🚀 启动兴邦金租 AI Native 智能决策系统"
echo "Starting mini OpenClaw"
# 等待 ERP 数据库就绪(如果配置了)
if [ ! -z "$ERP_DB_HOST" ]; then
echo "⏳ 等待 ERP 数据库连接..."
until pg_isready -h $ERP_DB_HOST -p $ERP_DB_PORT -U $ERP_DB_USER; do
echo "数据库未就绪,2秒后重试..."
sleep 2
done
echo "✅ ERP 数据库已连接"
# An ERP connection is optional for the stable demo. If it is configured,
# wait for it before starting the application; otherwise start immediately.
if [[ -n "${ERP_DB_HOST:-}" ]]; then
if command -v pg_isready >/dev/null 2>&1; then
echo "Waiting for ERP database at ${ERP_DB_HOST}:${ERP_DB_PORT:-5432}..."
until pg_isready -h "${ERP_DB_HOST}" -p "${ERP_DB_PORT:-5432}" -U "${ERP_DB_USER:-}" >/dev/null 2>&1; do
sleep 2
done
echo "ERP database is ready"
else
echo "pg_isready is unavailable; skipping ERP readiness check"
fi
fi
# 启动后端(后台)
echo "🔧 启动后端服务 (端口 8002)..."
cd /app/backend
python app.py &
echo "Starting backend on port 8002"
python /app/backend/app.py &
backend_pid=$!
# 启动前端(前台)
echo "🌐 启动前端服务 (端口 3000)..."
echo "Starting frontend on port 3000"
cd /app/frontend
npm start
npm start -- -H 0.0.0.0 -p 3000 &
frontend_pid=$!
cleanup() {
kill "${frontend_pid}" "${backend_pid}" 2>/dev/null || true
}
trap cleanup TERM INT EXIT
# Stop the container if either service exits; Docker can then restart it.
wait -n "${backend_pid}" "${frontend_pid}"