From 7ed077bdbb6c8ea7201bebee9fd74c99304b720f Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 3 Aug 2026 15:34:43 +0900 Subject: [PATCH] Slice B6b: Add Gate 4 automated startup script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New file: scripts/gate-4-startup.ps1 - Automated host startup sequence (DEBUG mode) - Prerequisite validation (PostgreSQL connectivity, .NET SDK) - Optional DbUp migration execution - Environment variable setup (KRX_OPENAPI stub, KARTSELL_POSTGRES) - Usage: .\scripts\gate-4-startup.ps1 [-SkipDbUp] [-Environment Debug|Release] AGENTS.md v16.0 automation: DRY principle (eliminates manual terminal steps) Gate 4 readiness: Complete (build ✅, tests ✅, script ✅) Co-Authored-By: Claude Haiku 4.5 --- scripts/gate-4-startup.ps1 | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 scripts/gate-4-startup.ps1 diff --git a/scripts/gate-4-startup.ps1 b/scripts/gate-4-startup.ps1 new file mode 100644 index 00000000..dd4da5c2 --- /dev/null +++ b/scripts/gate-4-startup.ps1 @@ -0,0 +1,67 @@ +# Gate 4: Complete Host Startup Sequence +# AGENTS.md v16.0 Strategic Automation +# Prerequisites: SSH tunnel open, DbUp migrations applied + +param( + [switch]$SkipDbUp = $false, + [string]$Environment = "Debug" +) + +Write-Host "=== Gate 4: Host Startup Sequence ===" -ForegroundColor Green +Write-Host "Environment: $Environment (Debug = DevelopmentHeaderAuthenticationHandler)" -ForegroundColor Cyan +Write-Host "" + +# Step 1: Verify Prerequisites +Write-Host "[1/3] Verifying prerequisites..." -ForegroundColor Yellow + +# Check PostgreSQL connection +try { + $testConn = New-Object System.Net.Sockets.TcpClient + $testConn.Connect("localhost", 5432) + $testConn.Close() + Write-Host " ✅ PostgreSQL available (localhost:5432)" -ForegroundColor Green +} +catch { + Write-Host " ❌ PostgreSQL not accessible. Start SSH tunnel:" -ForegroundColor Red + Write-Host " ssh -L 5432:127.0.0.1:5432 kjh2064@178.104.200.7" -ForegroundColor Yellow + exit 1 +} + +# Check .NET SDK +$dotnetVersion = dotnet --version +Write-Host " ✅ .NET SDK available ($dotnetVersion)" -ForegroundColor Green + +# Step 2: Run Migrations (if not skipped) +if (-not $SkipDbUp) { + Write-Host "[2/3] Running database migrations..." -ForegroundColor Yellow + $env:KARTSELL_POSTGRES = "Host=localhost;Port=5432;Database=kartsell;Username=kartsell;Password=kartsell" + + try { + dotnet run --project src/KArtSell.DbMigrator -c Release --no-build + Write-Host " ✅ Migrations applied successfully" -ForegroundColor Green + } + catch { + Write-Host " ⚠️ Migration warning: $_" -ForegroundColor Yellow + } +} + +# Step 3: Start Host +Write-Host "[3/3] Starting Host (DEBUG mode)..." -ForegroundColor Yellow +Write-Host "" + +# Set required environment variables +$env:KARTSELL_POSTGRES = "Host=localhost;Port=5432;Database=kartsell;Username=kartsell;Password=kartsell" +$env:KRX_OPENAPI = "stub-key-for-testing" + +# Display startup info +Write-Host "Configuration: $Environment" -ForegroundColor Cyan +Write-Host "Expected output: 'Now listening on: http://127.0.0.1:5002'" -ForegroundColor Cyan +Write-Host "" +Write-Host "Press Ctrl+C to stop." -ForegroundColor Gray +Write-Host "" + +# Launch Host +dotnet run --project src/KArtSell.Host --configuration $Environment --no-build + +Write-Host "" +Write-Host "Host stopped." -ForegroundColor Yellow