70 lines
2.8 KiB
PowerShell
70 lines
2.8 KiB
PowerShell
# Check deployment status on server
|
|
param(
|
|
[string]$Server = "45.249.208.118",
|
|
[string]$User = "root",
|
|
[string]$Password = "lxvhNYFZ4160",
|
|
[string]$ProjectPath = "/root/youyidian-3d"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Check Deployment Status" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
|
|
if (-not (Test-Path $plinkPath)) {
|
|
Write-Host "Error: plink.exe not found" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Check Docker containers status
|
|
Write-Host "[1/4] Checking Docker containers status..." -ForegroundColor Yellow
|
|
$checkCmd = "cd $ProjectPath && docker compose ps"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$checkCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check if containers are building
|
|
Write-Host "[2/4] Checking if containers are building..." -ForegroundColor Yellow
|
|
$checkCmd = "docker ps -a | grep -E 'youyidian|CONTAINER' | head -5"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$checkCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check application logs
|
|
Write-Host "[3/4] Checking application logs (last 30 lines)..." -ForegroundColor Yellow
|
|
$checkCmd = "cd $ProjectPath && docker compose logs app --tail=30 2>&1 || echo 'No logs yet'"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$checkCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check if deployment file exists
|
|
Write-Host "[4/4] Checking deployment files..." -ForegroundColor Yellow
|
|
$checkCmd = "cd $ProjectPath && ls -la project-deploy.tar.gz 2>/dev/null && echo 'Deployment file exists' || echo 'Deployment file not found'"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$checkCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
Write-Host $result
|
|
Write-Host ""
|
|
|
|
# Check Docker build process
|
|
Write-Host "[5/5] Checking Docker build process..." -ForegroundColor Yellow
|
|
$checkCmd = "ps aux | grep -E 'docker.*build|docker.*compose' | grep -v grep | head -5"
|
|
$plinkCmd = "`"$plinkPath`" -ssh -pw `"$Password`" -batch ${User}@${Server} `"$checkCmd`""
|
|
$result = cmd /c $plinkCmd 2>&1
|
|
if ($result -match "docker") {
|
|
Write-Host "Docker build process is running:" -ForegroundColor Green
|
|
Write-Host $result
|
|
} else {
|
|
Write-Host "No active Docker build process found" -ForegroundColor Yellow
|
|
}
|
|
Write-Host ""
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Status check complete" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "" |