mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-01 01:17:04 +00:00
- FastAPI backend with Python - React + Vite admin panel - PostgreSQL database - Trendyol marketplace analytics - GitHub Actions CI/CD workflow Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Bash
41 lines
1.2 KiB
Bash
#!/bin/bash
|
|
# Startup script for Trendyol Product Dashboard Backend
|
|
# Handles database migrations before starting the application
|
|
|
|
set -e
|
|
|
|
echo "🚀 Starting Trendyol Product Dashboard Backend..."
|
|
|
|
# Database URL from environment
|
|
DB_URL="${DATABASE_URL:-postgresql://postgres:trendyol123@postgres:5432/trendyol_db}"
|
|
echo "📦 Database: PostgreSQL"
|
|
|
|
# Wait for PostgreSQL to be ready (in case depends_on isn't enough)
|
|
echo "⏳ Waiting for PostgreSQL to be ready..."
|
|
MAX_RETRIES=30
|
|
RETRY_COUNT=0
|
|
|
|
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
|
if python -c "from sqlalchemy import create_engine; e = create_engine('$DB_URL'); e.connect()" 2>/dev/null; then
|
|
echo "✅ PostgreSQL is ready!"
|
|
break
|
|
fi
|
|
RETRY_COUNT=$((RETRY_COUNT + 1))
|
|
echo " Attempt $RETRY_COUNT/$MAX_RETRIES - PostgreSQL not ready, waiting..."
|
|
sleep 2
|
|
done
|
|
|
|
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
|
echo "❌ Failed to connect to PostgreSQL after $MAX_RETRIES attempts"
|
|
exit 1
|
|
fi
|
|
|
|
# Run migrations
|
|
echo "🔄 Running database migrations..."
|
|
alembic upgrade head
|
|
echo "✅ Migrations completed!"
|
|
|
|
# Start the FastAPI application
|
|
echo "🌐 Starting FastAPI server on port 8001..."
|
|
exec uvicorn main:app --host 0.0.0.0 --port 8001 --log-level info
|