mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-26 02:59:37 +00:00
f23a6df80b
Pass 1 (correctness sweep): - All native invocations (mysql, mysqld init, winget, curl downloads, cargo run, seed curl) now go through Invoke-Native, so a caller capturing the scripts' output can never turn ordinary stderr (warnings, progress) into a terminating NativeCommandError under Stop preference - Provisioning DDL feeds through a temp file + `source` and prints the mysql output when it fails (with the MYSQL_ROOT_PASSWORD hint) - Get-MySqlCount distinguishes "table empty" (0) from "query failed" (-1); bootstrap and doctor no longer misread a failed COUNT as unseeded - diesel_cli that is present but broken (moved libmysql.dll) is detected via an exit-code probe and reinstalled with --force - Shared Add-BuildToolsToSession maps winget install dirs + LIBCLANG_PATH in bootstrap, doctor, and run_backend_dev (cargo run may recompile); the tools check maps PATH before probing so re-runs skip winget entirely - my.ini values quoted (clone paths with spaces); service-start timeouts point at the .devstack log files Pass 2 (live retest matrix, all green on this machine): - Full re-run with output captured in-PowerShell: exit 0, no NativeCommandError - Wiped-state rebuild (mysql-data/my.ini/redis/secrets deleted): re-init, re-provision, 281 migrations replayed, seeds + secrets regenerated, backend booted, demo user recreated via /v1/create_account, doctor 0 fail / 0 warn - Failure paths: seed without backend and doctor without services both die cleanly with actionable messages and exit 1; stop_dev_services frees both ports gracefully
53 lines
2.0 KiB
PowerShell
53 lines
2.0 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 (see $LogsDir\mysqld.err.log and the .err file in $MySqlDataDir)" | 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 (see $LogsDir\redis.err.log)" | Out-Null
|
|
Write-Log "Redis is up."
|
|
}
|
|
|
|
if ($MyInvocation.InvocationName -ne '.') {
|
|
Start-DevMySql
|
|
Start-DevRedis
|
|
}
|