@woai
πŸͺŸ Add Windows deployment scripts and documentation - PowerShell and Batch scripts for Windows Server deployment, Complete Windows Services setup with NSSM, Firewall configuration, .env template creation, Detailed troubleshooting guide in DEPLOYMENT_WINDOWS.md
6bf65c9
@echo off
REM πŸš€ YouTube Metadata Extractor - Windows Deployment (Batch)
REM Simple deployment script for Windows
echo πŸš€ Starting deployment of YouTube Metadata Extractor on Windows...
REM Check if running as Administrator
net session >nul 2>&1
if %errorLevel% == 0 (
echo βœ… Running as Administrator
) else (
echo ❌ This script must be run as Administrator
echo Please right-click this file and select "Run as administrator"
pause
exit /b 1
)
REM Set configuration
set PROJECT_DIR=%USERPROFILE%\YouTube
set REPO_URL=https://huggingface.co/spaces/dzianisBY/YouTube_Creator_MetaData
echo βœ… Installing Chocolatey (if not present)...
where choco >nul 2>&1
if %errorLevel% == 0 (
echo Chocolatey already installed
) else (
powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"
call refreshenv
)
echo βœ… Installing Python and Git...
choco install python git -y
call refreshenv
echo βœ… Creating project directory...
if not exist "%PROJECT_DIR%" mkdir "%PROJECT_DIR%"
cd /d "%PROJECT_DIR%"
echo βœ… Cloning repository...
if exist ".git" (
git pull origin main
) else (
git clone %REPO_URL% .
)
echo βœ… Setting up Python virtual environment...
python -m venv .venv
call .venv\Scripts\activate.bat
echo βœ… Installing Python dependencies...
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r telegram_requirements.txt
echo βœ… Creating .env template...
if not exist ".env" (
echo # YouTube API Configuration > .env
echo YOUTUBE_API_KEY=your_youtube_api_key_here >> .env
echo. >> .env
echo # Telegram Bot Configuration >> .env
echo TELEGRAM_TOKEN=your_telegram_bot_token_here >> .env
echo. >> .env
echo # MCP Server Configuration >> .env
echo MCP_BASE_URL=https://youtube-bot.tuttech.net/api/mcp >> .env
echo. >> .env
echo # Gemini AI Configuration >> .env
echo GEMINI_API_KEY=your_gemini_api_key_here >> .env
echo. >> .env
echo # Server Configuration >> .env
echo HOST=0.0.0.0 >> .env
echo PORT=8080 >> .env
echo ⚠️ Created .env template file
echo ⚠️ Please edit %PROJECT_DIR%\.env with your actual API keys!
)
echo βœ… Creating startup scripts...
echo @echo off > start-api.bat
echo cd /d "%PROJECT_DIR%" >> start-api.bat
echo call .venv\Scripts\activate.bat >> start-api.bat
echo python main.py >> start-api.bat
echo @echo off > start-bot.bat
echo cd /d "%PROJECT_DIR%" >> start-bot.bat
echo call .venv\Scripts\activate.bat >> start-bot.bat
echo python run_telegram_bot.py >> start-bot.bat
echo βœ… Installing NSSM for Windows Services...
choco install nssm -y
echo βœ… Creating Windows Services...
nssm remove "YouTube-API" confirm >nul 2>&1
nssm remove "YouTube-Bot" confirm >nul 2>&1
nssm install "YouTube-API" "%PROJECT_DIR%\start-api.bat"
nssm set "YouTube-API" DisplayName "YouTube MCP API Server"
nssm set "YouTube-API" Description "YouTube Metadata Extractor API Server"
nssm set "YouTube-API" Start SERVICE_AUTO_START
nssm install "YouTube-Bot" "%PROJECT_DIR%\start-bot.bat"
nssm set "YouTube-Bot" DisplayName "YouTube Telegram Bot"
nssm set "YouTube-Bot" Description "YouTube Metadata Extractor Telegram Bot"
nssm set "YouTube-Bot" Start SERVICE_AUTO_START
nssm set "YouTube-Bot" DependOnService "YouTube-API"
echo βœ… Starting services...
net start "YouTube-API"
timeout /t 5 /nobreak >nul
net start "YouTube-Bot"
echo βœ… Configuring Windows Firewall...
netsh advfirewall firewall add rule name="YouTube API Server" dir=in action=allow protocol=TCP localport=8080 >nul 2>&1
echo.
echo βœ… Deployment completed!
echo.
echo πŸ“‹ Next steps:
echo 1. Edit %PROJECT_DIR%\.env with your API keys
echo 2. Restart services: net stop "YouTube-API" "YouTube-Bot" ^& net start "YouTube-API" "YouTube-Bot"
echo 3. Check services: sc query "YouTube-API" ^& sc query "YouTube-Bot"
echo.
echo πŸ”— Service URLs:
echo - API Server: http://localhost:8080
echo - Health Check: http://localhost:8080/health
echo.
echo πŸ“± Service Management:
echo - Start: net start "YouTube-API" "YouTube-Bot"
echo - Stop: net stop "YouTube-API" "YouTube-Bot"
echo - Status: sc query "YouTube-API" ^& sc query "YouTube-Bot"
echo.
pause