130 lines
3.2 KiB
Batchfile
130 lines
3.2 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
set "ROOT=%~dp0"
|
|
set "BACKEND_DIR=%ROOT%backend"
|
|
set "VENV_DIR=%BACKEND_DIR%\.venv"
|
|
set "VENV_PYTHON=%VENV_DIR%\Scripts\python.exe"
|
|
|
|
if /i "%~1"==":run_backend" goto run_backend
|
|
if /i "%~1"==":run_frontend" goto run_frontend
|
|
|
|
cd /d "%ROOT%"
|
|
|
|
echo [1/6] Checking Python...
|
|
set "PYTHON_CMD="
|
|
where py >nul 2>nul
|
|
if not errorlevel 1 (
|
|
py -3 -c "import sys" >nul 2>nul
|
|
if not errorlevel 1 set "PYTHON_CMD=py -3"
|
|
)
|
|
|
|
if not defined PYTHON_CMD (
|
|
where python >nul 2>nul
|
|
if not errorlevel 1 (
|
|
python -c "import sys" >nul 2>nul
|
|
if not errorlevel 1 set "PYTHON_CMD=python"
|
|
)
|
|
)
|
|
|
|
if not defined PYTHON_CMD (
|
|
echo A working Python 3 installation was not found.
|
|
echo Install Python 3.11 or later, then make sure py -3 or python works in a new terminal.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [2/6] Checking npm...
|
|
where npm >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo npm was not found in PATH.
|
|
echo Install Node.js, then rerun this script.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [3/6] Checking backend environment...
|
|
if exist "%BACKEND_DIR%\.env" (
|
|
echo Found backend\.env.
|
|
echo Source mode will still prefer local SQLite and local storage for one-click startup.
|
|
) else (
|
|
echo backend\.env was not found.
|
|
echo The backend will start with built-in defaults ^(SQLite, local storage, mock task flow^).
|
|
)
|
|
|
|
set "VENV_READY="
|
|
if exist "%VENV_PYTHON%" (
|
|
"%VENV_PYTHON%" -c "import sys" >nul 2>nul
|
|
if not errorlevel 1 set "VENV_READY=1"
|
|
)
|
|
|
|
if not defined VENV_READY (
|
|
if exist "%VENV_DIR%" (
|
|
echo Existing backend virtual environment is broken or stale. Recreating it...
|
|
rmdir /s /q "%VENV_DIR%"
|
|
if exist "%VENV_DIR%" (
|
|
echo Failed to remove the broken backend virtual environment.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
echo [4/6] Creating backend virtual environment...
|
|
%PYTHON_CMD% -m venv "%VENV_DIR%"
|
|
if errorlevel 1 (
|
|
echo Failed to create backend virtual environment.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo Installing backend dependencies...
|
|
"%VENV_PYTHON%" -m pip install --disable-pip-version-check -r "%BACKEND_DIR%\requirements.txt"
|
|
if errorlevel 1 (
|
|
echo Failed to install backend dependencies.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
) else (
|
|
echo [4/6] Backend virtual environment already exists.
|
|
)
|
|
|
|
if not exist "%ROOT%node_modules" (
|
|
echo [5/6] Installing frontend dependencies...
|
|
call npm install
|
|
if errorlevel 1 (
|
|
echo Failed to install frontend dependencies.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
) else (
|
|
echo [5/6] Frontend dependencies already exist.
|
|
)
|
|
|
|
echo [6/6] Starting backend and unified frontend...
|
|
start "AIVideo Backend" cmd /k call "%~f0" :run_backend
|
|
start "AIVideo Frontend" cmd /k call "%~f0" :run_frontend
|
|
|
|
echo.
|
|
echo User UI: http://localhost:3000
|
|
echo Admin UI: http://localhost:3000/admin/login
|
|
echo API: http://localhost:8000
|
|
echo.
|
|
echo Two windows have been opened for backend and frontend.
|
|
pause
|
|
goto :eof
|
|
|
|
:run_backend
|
|
cd /d "%BACKEND_DIR%"
|
|
set "DATABASE_URL=sqlite:///./aivideo.sqlite3"
|
|
set "CELERY_TASK_ALWAYS_EAGER=true"
|
|
set "STORAGE_PROVIDER=local"
|
|
set "LOCAL_STORAGE_PATH=storage_data"
|
|
set "STORAGE_PUBLIC_BASE_URL=http://127.0.0.1:8000/storage"
|
|
"%VENV_PYTHON%" -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
|
goto :eof
|
|
|
|
:run_frontend
|
|
cd /d "%ROOT%"
|
|
npm run dev
|
|
goto :eof
|