Files
aivideo/start-aivideo.bat

87 lines
2.4 KiB
Batchfile

@echo off
setlocal
set "ROOT=%~dp0"
set "BACKEND_DIR=%ROOT%backend"
set "VENV_PYTHON=%BACKEND_DIR%\.venv\Scripts\python.exe"
set "SOURCE_BACKEND_ENV=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"
cd /d "%ROOT%"
echo [1/6] Checking Python...
set "PYTHON_CMD="
where py >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 set "PYTHON_CMD=python"
)
if not defined PYTHON_CMD (
echo Python was not found in PATH.
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^).
)
if not exist "%VENV_PYTHON%" (
echo [4/6] Creating backend virtual environment...
call %PYTHON_CMD% -m venv "%BACKEND_DIR%\.venv"
if errorlevel 1 (
echo Failed to create backend virtual environment.
pause
exit /b 1
)
echo Installing backend dependencies...
call "%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 "cd /d ""%BACKEND_DIR%"" && %SOURCE_BACKEND_ENV% && ""%VENV_PYTHON%"" -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"
start "AIVideo Frontend" cmd /k "cd /d ""%ROOT%"" && npm run dev"
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