forked from J-M-PUNK/tideway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
45 lines (38 loc) · 1.55 KB
/
Copy pathrun.ps1
File metadata and controls
45 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Dev launcher: starts FastAPI (:8000) and Vite (:5173) together.
# Ctrl+C stops both. Windows equivalent of run.sh.
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
$py = Join-Path $root '.venv\Scripts\python.exe'
if (-not (Test-Path $py)) {
Write-Error "No venv at $root\.venv - create one and run: pip install -r requirements.txt"
exit 1
}
$web = Join-Path $root 'web'
if (-not (Test-Path (Join-Path $web 'node_modules'))) {
Write-Host "Installing frontend deps..."
Push-Location $web
try { & npm install } finally { Pop-Location }
}
# Start-Process with -NoNewWindow pipes stdout/stderr into this console so
# both servers' logs interleave here, matching run.sh's behavior.
Write-Host "Starting FastAPI on http://127.0.0.1:8000"
$api = Start-Process -FilePath $py `
-ArgumentList '-m', 'uvicorn', 'server:app', '--host', '127.0.0.1', '--port', '8000', '--reload' `
-WorkingDirectory $root -PassThru -NoNewWindow
Write-Host "Starting Vite on http://127.0.0.1:5173"
# npm on Windows is npm.cmd; Start-Process can't invoke .cmd scripts
# directly, so route through cmd /c.
$webProc = Start-Process -FilePath 'cmd.exe' `
-ArgumentList '/c', 'npm', 'run', 'dev', '--', '--host', '127.0.0.1', '--port', '5173' `
-WorkingDirectory $web -PassThru -NoNewWindow
try {
Wait-Process -Id $api.Id, $webProc.Id
}
finally {
foreach ($p in @($api, $webProc)) {
if ($p -and -not $p.HasExited) {
Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue
}
}
}