-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-backend.ps1
More file actions
30 lines (26 loc) · 1.08 KB
/
Copy pathstart-backend.ps1
File metadata and controls
30 lines (26 loc) · 1.08 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
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$BackendRoot = Join-Path $ProjectRoot "backend"
$BackendVenv = Join-Path $BackendRoot ".venv"
$BackendPython = Join-Path $BackendVenv "Scripts\python.exe"
$BackendAlembic = Join-Path $BackendVenv "Scripts\alembic.exe"
function Invoke-Native([scriptblock]$Command, [string]$ErrorMessage) {
& $Command
if ($LASTEXITCODE -ne 0) {
throw "$ErrorMessage Код завершения: $LASTEXITCODE"
}
}
if (-not (Test-Path $BackendPython) -or -not (Test-Path $BackendAlembic)) {
throw "Backend ещё не настроен. Сначала выполните .\setup.ps1"
}
Push-Location $BackendRoot
try {
Invoke-Native { & $BackendAlembic upgrade head } "Не удалось применить миграции Alembic."
& $BackendPython -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
if ($LASTEXITCODE -ne 0) {
throw "Backend завершился с ошибкой. Код: $LASTEXITCODE"
}
} finally {
Pop-Location
}