@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 |