mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-12 06:40:58 +04:30
Initial commit: Meshkee CMS API
NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
CONTAINER="${POSTGRES_CONTAINER:-meshkee-postgres}"
|
||||
DB_USER="${POSTGRES_USER:-meshkee}"
|
||||
DB_NAME="${POSTGRES_DB:-meshkee_cms}"
|
||||
MAX_ATTEMPTS="${WAIT_MAX_ATTEMPTS:-60}"
|
||||
SLEEP_SECONDS="${WAIT_SLEEP_SECONDS:-1}"
|
||||
|
||||
echo "Waiting for PostgreSQL in container '$CONTAINER'..."
|
||||
|
||||
for ((attempt = 1; attempt <= MAX_ATTEMPTS; attempt++)); do
|
||||
if docker exec "$CONTAINER" pg_isready -U "$DB_USER" -d "$DB_NAME" >/dev/null 2>&1; then
|
||||
if docker exec "$CONTAINER" psql -U "$DB_USER" -d "$DB_NAME" -tAc \
|
||||
"SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'users'" \
|
||||
2>/dev/null | grep -q 1; then
|
||||
echo "PostgreSQL is ready."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$attempt" -eq "$MAX_ATTEMPTS" ]]; then
|
||||
echo "PostgreSQL did not become ready within ${MAX_ATTEMPTS}s." >&2
|
||||
echo "Check: docker compose ps && docker compose logs postgres" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep "$SLEEP_SECONDS"
|
||||
done
|
||||
Reference in New Issue
Block a user