Files
artcraft/script/bootstrap/windows/start_dev_services.ps1
T
Tanish Manku 345cbe766a Dev infra: Windows-first bootstrap - portable MySQL/Redis stack, no WSL required
Adds script/bootstrap/windows/*.ps1 (PowerShell 5.1-compatible) as the primary
bootstrap path, validated end-to-end on a real Windows 10 machine:

- Portable stack under gitignored .devstack/: MySQL 8.4.11 (official
  cdn.mysql.com zip, --initialize-insecure, bound to 127.0.0.1) and Redis
  5.0.14.1 (tporadowski build, REDIS_ZIP_URL-overridable) run as plain user
  processes - no admin, no services, no WSL, no Docker
- bootstrap_dev_stack.ps1: winget-installs missing build tools (Strawberry
  Perl, NASM, LLVM; wreq's BoringSSL + aws-lc-sys need them), compiles
  diesel_cli against the portable MySQL's own client lib
  (MYSQLCLIENT_LIB_DIR), runs all 281 migrations, seeds roles/badges
  idempotently, generates the dummy secrets env (plus TEMP_DIR for Windows),
  builds storyteller-web, installs frontend deps
- start/stop_dev_services.ps1, run_backend_dev.ps1, seed_demo_user.ps1,
  dev_stack_doctor.ps1 mirror the bash variants
- Invoke-Native (cmd /c ... 2>&1) wraps long-running native calls so PS 5.1
  cannot turn harmless stderr warnings into terminating NativeCommandErrors
  when output is captured; my.ini uses forward slashes (MySQL escape rules)

Verified on this machine: 281/281 migrations applied, backend built (3m05s)
and booted on :12345 with dummy secrets, POST /v1/create_account +
/v1/login round-trip succeeded, webapp dev server served on :4201, doctor
reports 0 failures. The bash scripts remain the Linux/WSL2/CI path.
2026-07-28 21:23:06 -07:00

53 lines
1.9 KiB
PowerShell

# Start (or verify) the portable MySQL and Redis processes under .devstack/.
# Idempotent: already-running services are left alone. Safe to call from other
# scripts via dot-sourcing (defines Start-DevMySql / Start-DevRedis) or run
# directly.
param()
. (Join-Path $PSScriptRoot "common.ps1")
function Start-DevMySql {
if (Test-TcpPort 3306) {
Write-Log "MySQL already listening on 3306."
return
}
$mysqld = Join-Path $MySqlBaseDir "bin\mysqld.exe"
if (-not (Test-Path $mysqld)) {
Die "Portable MySQL not installed at $MySqlBaseDir. Run bootstrap_dev_stack.ps1 first."
}
if (-not (Test-Path (Join-Path $MySqlDataDir "mysql"))) {
Die "MySQL data directory not initialized at $MySqlDataDir. Run bootstrap_dev_stack.ps1 first."
}
Write-Log "Starting mysqld (portable, data in .devstack\mysql-data)..."
Start-DevProcess -Name "mysqld" -Exe $mysqld -Arguments @("--defaults-file=`"$MySqlIniPath`"") | Out-Null
Wait-ForCondition { Test-TcpPort 3306 } 60 "MySQL to listen on 3306" | Out-Null
Write-Log "MySQL is up."
}
function Start-DevRedis {
if (Test-TcpPort 6379) {
Write-Log "Redis already listening on 6379."
return
}
$redis = Join-Path $RedisDir "redis-server.exe"
if (-not (Test-Path $redis)) {
Die "Portable Redis not installed at $RedisDir. Run bootstrap_dev_stack.ps1 first."
}
Write-Log "Starting redis-server (portable)..."
# Keep the working dir (dump.rdb etc.) inside .devstack. NB: Start-Process
# rejects empty-string ArgumentList elements, so pass `--save ""` as one
# token to disable snapshotting.
Start-DevProcess -Name "redis" -Exe $redis -Arguments @(
"--port", "6379",
"--save", "`"`"",
"--dir", "`"$RedisDir`""
) | Out-Null
Wait-ForCondition { Test-TcpPort 6379 } 30 "Redis to listen on 6379" | Out-Null
Write-Log "Redis is up."
}
if ($MyInvocation.InvocationName -ne '.') {
Start-DevMySql
Start-DevRedis
}