File size: 3,351 Bytes
6bf65c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# π YouTube Metadata Extractor - Windows Update Script
# This script updates the project on a Windows Server
Write-Host "π Updating YouTube Metadata Extractor on Windows..." -ForegroundColor Green
# Configuration
$ProjectDir = "$env:USERPROFILE\YouTube"
# Function to print colored output
function Write-Status {
param($Message)
Write-Host "β
$Message" -ForegroundColor Green
}
function Write-Warning {
param($Message)
Write-Host "β οΈ $Message" -ForegroundColor Yellow
}
function Write-Error {
param($Message)
Write-Host "β $Message" -ForegroundColor Red
}
# Check if project directory exists
if (!(Test-Path $ProjectDir)) {
Write-Error "Project directory not found: $ProjectDir"
Write-Error "Please run deploy.ps1 first to set up the project"
exit 1
}
Set-Location $ProjectDir
# Stop services
Write-Status "Stopping Windows Services..."
try {
Stop-Service "YouTube-API" -Force -ErrorAction SilentlyContinue
Stop-Service "YouTube-Bot" -Force -ErrorAction SilentlyContinue
Start-Sleep 3
} catch {
Write-Warning "Could not stop services (they may not be running)"
}
# Pull latest changes
Write-Status "Pulling latest changes from repository..."
git pull origin main
# Activate virtual environment and update dependencies
Write-Status "Updating Python dependencies..."
& "$ProjectDir\.venv\Scripts\Activate.ps1"
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r telegram_requirements.txt
# Start services
Write-Status "Starting Windows Services..."
try {
Start-Service "YouTube-API"
Start-Sleep 5
Start-Service "YouTube-Bot"
} catch {
Write-Error "Could not start services. They may need to be created first."
Write-Error "Please run deploy.ps1 to set up services."
}
# Check service status
Write-Status "Checking service status..."
Start-Sleep 5
try {
$apiStatus = Get-Service "YouTube-API" -ErrorAction SilentlyContinue
$botStatus = Get-Service "YouTube-Bot" -ErrorAction SilentlyContinue
if ($apiStatus -and $apiStatus.Status -eq "Running") {
Write-Status "YouTube API Server is running"
} else {
Write-Error "YouTube API Server is not running"
if ($apiStatus) {
Get-Service "YouTube-API" | Format-Table
}
}
if ($botStatus -and $botStatus.Status -eq "Running") {
Write-Status "YouTube Telegram Bot is running"
} else {
Write-Error "YouTube Telegram Bot is not running"
if ($botStatus) {
Get-Service "YouTube-Bot" | Format-Table
}
}
} catch {
Write-Error "Could not check service status. Services may not be installed."
}
Write-Status "Update completed!"
Write-Host ""
Write-Host "π Useful commands:" -ForegroundColor Cyan
Write-Host "- Check service status: Get-Service YouTube-API, YouTube-Bot"
Write-Host "- Start services: Start-Service YouTube-API, YouTube-Bot"
Write-Host "- Stop services: Stop-Service YouTube-API, YouTube-Bot"
Write-Host "- Restart services: Restart-Service YouTube-API, YouTube-Bot"
Write-Host "- Check logs: Get-EventLog -LogName Application -Source YouTube*"
Write-Host "- Manual start API: cd '$ProjectDir'; .\.venv\Scripts\Activate.ps1; python main.py"
Write-Host "- Manual start Bot: cd '$ProjectDir'; .\.venv\Scripts\Activate.ps1; python run_telegram_bot.py" |