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.

setup-local-dev.sh 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # Setup script for local development with market-data.local domain
  3. # This script automates the hosts file entry required for MT5 EA connectivity
  4. set -e
  5. DOMAIN="market-data.local"
  6. HOSTS_ENTRY="127.0.0.1 ${DOMAIN}"
  7. HOSTS_FILE="/etc/hosts"
  8. echo "🚀 Setting up local development environment for Market Data Service"
  9. echo ""
  10. # Check if running on macOS
  11. if [[ "$OSTYPE" == "darwin"* ]]; then
  12. OS="macOS"
  13. elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
  14. OS="Linux"
  15. else
  16. echo "⚠️ Warning: Unsupported OS. Please manually add to hosts file:"
  17. echo " ${HOSTS_ENTRY}"
  18. exit 1
  19. fi
  20. # Check if entry already exists
  21. if grep -q "${DOMAIN}" "${HOSTS_FILE}" 2>/dev/null; then
  22. echo "✅ Hosts entry for ${DOMAIN} already exists"
  23. echo ""
  24. echo "Current entry:"
  25. grep "${DOMAIN}" "${HOSTS_FILE}" | head -1
  26. echo ""
  27. echo "✅ Setup complete! You can now use http://${DOMAIN}"
  28. exit 0
  29. fi
  30. # Check if running as root (required for hosts file modification)
  31. if [ "$EUID" -ne 0 ]; then
  32. echo "📝 Adding ${DOMAIN} to hosts file requires administrator privileges"
  33. echo ""
  34. # Try to use osascript on macOS for interactive password prompt
  35. if [[ "$OSTYPE" == "darwin"* ]] && command -v osascript >/dev/null 2>&1; then
  36. echo " Prompting for administrator password..."
  37. echo ""
  38. # Use osascript to run the command with admin privileges
  39. osascript -e "do shell script \"echo '${HOSTS_ENTRY}' >> ${HOSTS_FILE}\" with administrator privileges" 2>&1
  40. if [ $? -ne 0 ]; then
  41. echo ""
  42. echo "❌ Failed to add entry. Please run manually:"
  43. echo " sudo bash scripts/setup-local-dev.sh"
  44. echo ""
  45. echo "Or manually add this line to ${HOSTS_FILE}:"
  46. echo " ${HOSTS_ENTRY}"
  47. exit 1
  48. fi
  49. else
  50. # Not macOS or osascript not available, require manual sudo
  51. echo "Please run this script with sudo:"
  52. echo " sudo bash scripts/setup-local-dev.sh"
  53. echo ""
  54. echo "Or manually add this line to ${HOSTS_FILE}:"
  55. echo " ${HOSTS_ENTRY}"
  56. exit 1
  57. fi
  58. else
  59. # Already running as root, just add the entry
  60. echo "📝 Adding ${DOMAIN} to ${HOSTS_FILE}..."
  61. echo "${HOSTS_ENTRY}" >> "${HOSTS_FILE}"
  62. fi
  63. # Verify the entry was added
  64. if grep -q "${DOMAIN}" "${HOSTS_FILE}"; then
  65. echo "✅ Successfully added ${DOMAIN} to hosts file"
  66. echo ""
  67. echo "Added entry:"
  68. grep "${DOMAIN}" "${HOSTS_FILE}" | tail -1
  69. echo ""
  70. echo "✅ Setup complete!"
  71. echo ""
  72. echo "Next steps:"
  73. echo " 1. Start Docker services: docker-compose up -d"
  74. echo " 2. Test the domain: curl http://${DOMAIN}/health"
  75. echo " 3. Configure MT5 EA with: ApiBaseUrl = \"http://${DOMAIN}\""
  76. else
  77. echo "❌ Failed to add entry to hosts file"
  78. exit 1
  79. fi