loreal-video-optimizer/start.sh
2026-01-08 18:18:48 +05:30

117 lines
3.2 KiB
Bash
Executable file

#!/bin/bash
# Video Optimizer Startup Script
# Starts both backend and frontend for local development
echo "========================================="
echo "🎬 Video Optimizer - Startup"
echo "========================================="
echo ""
# Check if .env file exists
if [ ! -f ".env" ]; then
echo "❌ .env file not found!"
echo ""
echo " Please create a .env file from .env.example:"
echo " 1. Copy the template: cp .env.example .env"
echo " 2. Edit .env and add your Azure AD credentials"
echo " 3. Run this script again"
echo ""
exit 1
fi
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "❌ Virtual environment not found!"
echo ""
echo " Please set up the environment first:"
echo " 1. Create venv: python3 -m venv venv"
echo " 2. Activate venv: source venv/bin/activate"
echo " 3. Install dependencies: pip install -r backend/requirements.txt"
echo " 4. Run this script again"
echo ""
exit 1
fi
# Check if FFmpeg is installed
if ! command -v ffmpeg &> /dev/null; then
echo "⚠️ WARNING: FFmpeg is not installed!"
echo ""
echo " Video conversion will not work without FFmpeg."
echo " Install with:"
echo " - macOS: brew install ffmpeg"
echo " - Ubuntu/Debian: sudo apt-get install ffmpeg"
echo " - Windows: Download from https://ffmpeg.org/download.html"
echo ""
read -p " Continue anyway? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo ""
fi
# Activate virtual environment
echo "🔧 Activating virtual environment..."
source venv/bin/activate
# Load environment variables to display configuration
source .env 2>/dev/null
# Display configuration
echo ""
echo "📋 Configuration:"
echo " Environment: ${FLASK_ENV:-development}"
echo " Backend Port: ${BACKEND_PORT:-5000}"
echo " File Retention: ${FILE_RETENTION_HOURS:-24} hours"
echo " Max File Size: ${MAX_FILE_SIZE_MB:-500}MB"
echo ""
# Start backend server
echo "🚀 Starting backend server..."
cd backend
python app.py &
BACKEND_PID=$!
cd ..
# Wait for backend to start
echo " Waiting for backend to initialize..."
sleep 3
# Check if backend started successfully
if ! kill -0 $BACKEND_PID 2>/dev/null; then
echo ""
echo "❌ Backend failed to start!"
echo " Check backend/logs for errors"
exit 1
fi
# Start frontend server
echo "🌐 Starting frontend server..."
cd frontend
python3 -m http.server 3000 > /dev/null 2>&1 &
FRONTEND_PID=$!
cd ..
# Wait for frontend to start
sleep 1
echo ""
echo "========================================="
echo "✅ Application is running!"
echo "========================================="
echo ""
echo " Backend: http://localhost:${BACKEND_PORT:-5000}"
echo " Frontend: http://localhost:3000"
echo ""
echo " 👉 Open your browser: http://localhost:3000"
echo " 📚 Help page: http://localhost:3000/help.html"
echo " ⚙️ Admin panel: http://localhost:3000/admin.html"
echo ""
echo " Press Ctrl+C to stop all servers"
echo "========================================="
echo ""
# Wait for Ctrl+C
trap "echo ''; echo '🛑 Stopping servers...'; kill $BACKEND_PID $FRONTEND_PID 2>/dev/null; echo '✅ Servers stopped'; exit" INT
wait