Market Data Service is a high-performance financial data API that provides comprehensive Symbol prices of different markets through both RESTful endpoints and real-time WebSocket connections.

wait-for-db.sh 741B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. set -e
  3. # Wait for PostgreSQL to be ready
  4. # Usage: wait-for-db.sh [host] [port] [user] [database]
  5. host="${DB_HOST:-db}"
  6. port="${DB_PORT:-5432}"
  7. user="${DB_USER:-postgres}"
  8. database="${DB_NAME:-financial_data}"
  9. max_attempts=30
  10. attempt=0
  11. echo "Waiting for PostgreSQL to be ready at ${host}:${port}..."
  12. while [ $attempt -lt $max_attempts ]; do
  13. if PGPASSWORD="${DB_PASSWORD}" pg_isready -h "$host" -p "$port" -U "$user" -d "$database" >/dev/null 2>&1; then
  14. echo "PostgreSQL is ready!"
  15. exit 0
  16. fi
  17. attempt=$((attempt + 1))
  18. echo "Attempt $attempt/$max_attempts: PostgreSQL is not ready yet. Waiting..."
  19. sleep 2
  20. done
  21. echo "PostgreSQL failed to become ready after $max_attempts attempts"
  22. exit 1