Some checks failed
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 3s
LabFusion CI/CD Pipeline / api-docs (push) Failing after 3s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 2s
LabFusion CI/CD Pipeline / frontend (push) Failing after 2s
LabFusion CI/CD Pipeline / security-scan (push) Has been skipped
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
Docker Build and Push / build-and-push (push) Failing after 3m33s
Docker Build and Push / security-scan (push) Has been skipped
Docker Build and Push / deploy-staging (push) Has been skipped
Docker Build and Push / deploy-production (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 2s
Integration Tests / performance-tests (push) Has been skipped
209 lines
6.2 KiB
PowerShell
209 lines
6.2 KiB
PowerShell
# LabFusion Gitea Runners Management Script (PowerShell)
|
|
# Usage: .\scripts\manage-runners.ps1 [start|stop|restart|status|logs|clean]
|
|
|
|
param(
|
|
[Parameter(Position=0)]
|
|
[ValidateSet("start", "stop", "restart", "status", "logs", "clean", "help")]
|
|
[string]$Command = "help",
|
|
|
|
[Parameter(Position=1)]
|
|
[string]$RunnerName = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$ComposeFile = "docker-compose.runners.yml"
|
|
$EnvFile = ".env.runners"
|
|
|
|
# Helper functions
|
|
function Write-Info {
|
|
param([string]$Message)
|
|
Write-Host "[INFO] $Message" -ForegroundColor Blue
|
|
}
|
|
|
|
function Write-Success {
|
|
param([string]$Message)
|
|
Write-Host "[SUCCESS] $Message" -ForegroundColor Green
|
|
}
|
|
|
|
function Write-Warning {
|
|
param([string]$Message)
|
|
Write-Host "[WARNING] $Message" -ForegroundColor Yellow
|
|
}
|
|
|
|
function Write-Error {
|
|
param([string]$Message)
|
|
Write-Host "[ERROR] $Message" -ForegroundColor Red
|
|
}
|
|
|
|
# Check if .env.runners exists
|
|
function Test-EnvFile {
|
|
if (-not (Test-Path $EnvFile)) {
|
|
Write-Error "Environment file $EnvFile not found!"
|
|
Write-Info "Please copy env.runners.example to $EnvFile and configure it:"
|
|
Write-Info " Copy-Item env.runners.example $EnvFile"
|
|
Write-Info " # Edit $EnvFile with your Gitea instance URL and runner token"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Start runners
|
|
function Start-Runners {
|
|
Write-Info "Starting LabFusion Gitea runners..."
|
|
Test-EnvFile
|
|
|
|
docker-compose -f $ComposeFile --env-file $EnvFile up -d
|
|
|
|
Write-Success "Runners started successfully!"
|
|
Write-Info "Runners:"
|
|
Write-Info " - Heavy (Java/Python): labfusion-runner-heavy"
|
|
Write-Info " - Light (Node.js/Frontend): labfusion-runner-light"
|
|
Write-Info " - Docker (Integration): labfusion-runner-docker"
|
|
Write-Info " - Security (Scans): labfusion-runner-security"
|
|
|
|
# Wait a moment for health checks
|
|
Start-Sleep -Seconds 5
|
|
Show-Status
|
|
}
|
|
|
|
# Stop runners
|
|
function Stop-Runners {
|
|
Write-Info "Stopping LabFusion Gitea runners..."
|
|
|
|
docker-compose -f $ComposeFile down
|
|
|
|
Write-Success "Runners stopped successfully!"
|
|
}
|
|
|
|
# Restart runners
|
|
function Restart-Runners {
|
|
Write-Info "Restarting LabFusion Gitea runners..."
|
|
Stop-Runners
|
|
Start-Sleep -Seconds 2
|
|
Start-Runners
|
|
}
|
|
|
|
# Show runner status
|
|
function Show-Status {
|
|
Write-Info "LabFusion Gitea Runners Status:"
|
|
Write-Host ""
|
|
|
|
# Check if compose file exists
|
|
if (-not (Test-Path $ComposeFile)) {
|
|
Write-Error "Docker Compose file $ComposeFile not found!"
|
|
exit 1
|
|
}
|
|
|
|
# Show container status
|
|
docker-compose -f $ComposeFile ps
|
|
|
|
Write-Host ""
|
|
Write-Info "Runner Health Status:"
|
|
|
|
# Check each runner's health
|
|
$runners = @("labfusion-runner-heavy", "labfusion-runner-light", "labfusion-runner-docker", "labfusion-runner-security")
|
|
|
|
foreach ($runner in $runners) {
|
|
$container = docker ps --format "table {{.Names}}\t{{.Status}}" | Select-String $runner
|
|
if ($container) {
|
|
try {
|
|
$health = docker inspect --format='{{.State.Health.Status}}' $runner 2>$null
|
|
if ($health) {
|
|
switch ($health) {
|
|
"healthy" { Write-Success "$runner`: $health" }
|
|
"unhealthy" { Write-Error "$runner`: $health" }
|
|
"starting" { Write-Warning "$runner`: $health" }
|
|
default { Write-Warning "$runner`: $health" }
|
|
}
|
|
} else {
|
|
Write-Warning "$runner`: health check not available"
|
|
}
|
|
} catch {
|
|
Write-Warning "$runner`: health check failed"
|
|
}
|
|
} else {
|
|
Write-Error "$runner`: not running"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Show logs
|
|
function Show-Logs {
|
|
param([string]$Runner = "")
|
|
|
|
if ($Runner) {
|
|
Write-Info "Showing logs for $Runner..."
|
|
docker-compose -f $ComposeFile logs -f $Runner
|
|
} else {
|
|
Write-Info "Showing logs for all runners..."
|
|
docker-compose -f $ComposeFile logs -f
|
|
}
|
|
}
|
|
|
|
# Clean up runners and data
|
|
function Clean-Runners {
|
|
$response = Read-Host "This will remove all runners and their data. Are you sure? (y/N)"
|
|
|
|
if ($response -match "^[Yy]$") {
|
|
Write-Info "Cleaning up runners and data..."
|
|
|
|
# Stop and remove containers
|
|
docker-compose -f $ComposeFile down -v
|
|
|
|
# Remove volumes
|
|
try {
|
|
$volumes = docker volume ls -q | Where-Object { $_ -match "runner-data" }
|
|
if ($volumes) {
|
|
docker volume rm $volumes
|
|
}
|
|
docker volume rm shared-cache 2>$null
|
|
} catch {
|
|
Write-Warning "Some volumes could not be removed (this is normal if they don't exist)"
|
|
}
|
|
|
|
Write-Success "Cleanup completed!"
|
|
} else {
|
|
Write-Info "Cleanup cancelled."
|
|
}
|
|
}
|
|
|
|
# Show help
|
|
function Show-Help {
|
|
Write-Host "LabFusion Gitea Runners Management Script (PowerShell)"
|
|
Write-Host ""
|
|
Write-Host "Usage: .\scripts\manage-runners.ps1 [COMMAND] [RUNNER_NAME]"
|
|
Write-Host ""
|
|
Write-Host "Commands:"
|
|
Write-Host " start Start all runners"
|
|
Write-Host " stop Stop all runners"
|
|
Write-Host " restart Restart all runners"
|
|
Write-Host " status Show runner status and health"
|
|
Write-Host " logs Show logs for all runners"
|
|
Write-Host " logs [runner] Show logs for specific runner"
|
|
Write-Host " clean Remove all runners and data (destructive)"
|
|
Write-Host " help Show this help message"
|
|
Write-Host ""
|
|
Write-Host "Examples:"
|
|
Write-Host " .\scripts\manage-runners.ps1 start"
|
|
Write-Host " .\scripts\manage-runners.ps1 status"
|
|
Write-Host " .\scripts\manage-runners.ps1 logs labfusion-runner-heavy"
|
|
Write-Host " .\scripts\manage-runners.ps1 clean"
|
|
}
|
|
|
|
# Main script logic
|
|
switch ($Command) {
|
|
"start" { Start-Runners }
|
|
"stop" { Stop-Runners }
|
|
"restart" { Restart-Runners }
|
|
"status" { Show-Status }
|
|
"logs" { Show-Logs -Runner $RunnerName }
|
|
"clean" { Clean-Runners }
|
|
"help" { Show-Help }
|
|
default {
|
|
Write-Error "Unknown command: $Command"
|
|
Write-Host ""
|
|
Show-Help
|
|
exit 1
|
|
}
|
|
}
|