Files
mini-openclaw/docker-entrypoint.sh
T

36 lines
1.1 KiB
Bash
Raw Normal View History

2026-09-10 11:23:55 +08:00
#!/usr/bin/env bash
set -Eeuo pipefail
2026-09-10 11:23:55 +08:00
echo "Starting mini OpenClaw"
2026-09-10 11:23:55 +08:00
# 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
2026-09-10 11:23:55 +08:00
echo "Starting backend on port 8002"
python /app/backend/app.py &
backend_pid=$!
2026-09-10 11:23:55 +08:00
echo "Starting frontend on port 3000"
cd /app/frontend
2026-09-10 11:23:55 +08:00
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}"