36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
echo "Starting mini OpenClaw"
|
|
|
|
# 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 "Starting backend on port 8002"
|
|
python /app/backend/app.py &
|
|
backend_pid=$!
|
|
|
|
echo "Starting frontend on port 3000"
|
|
cd /app/frontend
|
|
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}"
|