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.

entrypoint.sh 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. set -e
  3. echo "Starting Market Data Service API container..."
  4. # Wait for database to be ready
  5. if [ -f /usr/local/bin/wait-for-db.sh ]; then
  6. /usr/local/bin/wait-for-db.sh
  7. else
  8. echo "Waiting for database using pg_isready..."
  9. host="${DB_HOST:-db}"
  10. port="${DB_PORT:-5432}"
  11. user="${DB_USER:-postgres}"
  12. max_attempts=30
  13. attempt=0
  14. while [ $attempt -lt $max_attempts ]; do
  15. if PGPASSWORD="${DB_PASSWORD}" pg_isready -h "$host" -p "$port" -U "$user" >/dev/null 2>&1; then
  16. echo "Database is ready!"
  17. break
  18. fi
  19. attempt=$((attempt + 1))
  20. echo "Waiting for database... ($attempt/$max_attempts)"
  21. sleep 2
  22. done
  23. if [ $attempt -eq $max_attempts ]; then
  24. echo "ERROR: Database failed to become ready"
  25. exit 1
  26. fi
  27. fi
  28. # Run database migrations
  29. echo "Running database migrations..."
  30. npx sequelize-cli db:migrate || {
  31. echo "ERROR: Database migration failed"
  32. exit 1
  33. }
  34. echo "Migrations completed successfully"
  35. # Start the application
  36. echo "Starting Node.js application..."
  37. exec "$@"