|
@@ -140,20 +140,38 @@ if (-not $GuiOnly) {
|
|
|
Push-Location $SpecDir
|
|
Push-Location $SpecDir
|
|
|
& python -m venv mvenv
|
|
& python -m venv mvenv
|
|
|
if ($LASTEXITCODE -ne 0) { Write-Fail "Failed to create spectrometer venv" }
|
|
if ($LASTEXITCODE -ne 0) { Write-Fail "Failed to create spectrometer venv" }
|
|
|
- & $SpecVenv -m pip install -q --upgrade pip
|
|
|
|
|
- & $SpecVenv -m pip install -q -r requirements.txt
|
|
|
|
|
- if ($LASTEXITCODE -ne 0) { Write-Fail "Failed to install spectrometer packages" }
|
|
|
|
|
Pop-Location
|
|
Pop-Location
|
|
|
Write-OK "Spectrometer venv created"
|
|
Write-OK "Spectrometer venv created"
|
|
|
} else {
|
|
} else {
|
|
|
Write-OK "Spectrometer venv found"
|
|
Write-OK "Spectrometer venv found"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ # Always sync packages (catches new deps after git pull)
|
|
|
|
|
+ Write-Host " Installing/updating spectrometer packages..." -ForegroundColor DarkGray
|
|
|
Push-Location $SpecDir
|
|
Push-Location $SpecDir
|
|
|
- & $SpecVenv manage.py migrate --noinput 2>&1 | Out-Null
|
|
|
|
|
|
|
+ & $SpecVenv -m pip install -q --upgrade pip
|
|
|
|
|
+ $pipOut = & $SpecVenv -m pip install -q -r requirements.txt 2>&1
|
|
|
|
|
+ $pipFailed = ($LASTEXITCODE -ne 0)
|
|
|
Pop-Location
|
|
Pop-Location
|
|
|
- Write-OK "Migrations applied"
|
|
|
|
|
|
|
+ if ($pipFailed) {
|
|
|
|
|
+ Write-Warn "pip install had issues:`n$pipOut"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Write-OK "Packages up to date"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # Migrations -- show output so errors are visible
|
|
|
|
|
+ Write-Host " Running migrations..." -ForegroundColor DarkGray
|
|
|
|
|
+ Push-Location $SpecDir
|
|
|
|
|
+ $migrateOut = & $SpecVenv manage.py migrate --noinput 2>&1
|
|
|
|
|
+ $migrateFailed = ($LASTEXITCODE -ne 0)
|
|
|
|
|
+ Pop-Location
|
|
|
|
|
+ if ($migrateFailed) {
|
|
|
|
|
+ Write-Warn "Migration warnings:`n$migrateOut"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Write-OK "Migrations applied"
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ # pico-tcp.exe
|
|
|
if (Test-Path $PicoExe) {
|
|
if (Test-Path $PicoExe) {
|
|
|
Start-Process $PicoExe -WindowStyle Normal
|
|
Start-Process $PicoExe -WindowStyle Normal
|
|
|
Write-OK "pico-tcp.exe started (visible window)"
|
|
Write-OK "pico-tcp.exe started (visible window)"
|
|
@@ -161,7 +179,7 @@ if (-not $GuiOnly) {
|
|
|
Write-Warn "bin\pico-tcp.exe not found -- ADC proxy not started"
|
|
Write-Warn "bin\pico-tcp.exe not found -- ADC proxy not started"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- # Check if runserver is already up by probing port 8000
|
|
|
|
|
|
|
+ # Django runserver -- run via "cmd /k" so window stays open on error
|
|
|
$specPort = Get-EnvPort "SPECTROMETER_PORT" "8000"
|
|
$specPort = Get-EnvPort "SPECTROMETER_PORT" "8000"
|
|
|
$alreadyUp = $false
|
|
$alreadyUp = $false
|
|
|
try {
|
|
try {
|
|
@@ -173,11 +191,15 @@ if (-not $GuiOnly) {
|
|
|
if ($alreadyUp) {
|
|
if ($alreadyUp) {
|
|
|
Write-OK "Spectrometer already responding on port $specPort"
|
|
Write-OK "Spectrometer already responding on port $specPort"
|
|
|
} else {
|
|
} else {
|
|
|
- Start-Process $SpecVenv `
|
|
|
|
|
- -ArgumentList "manage.py runserver 0.0.0.0:$specPort" `
|
|
|
|
|
|
|
+ # Title makes the window easy to find in the taskbar.
|
|
|
|
|
+ # /k keeps the window open even if Django crashes at startup.
|
|
|
|
|
+ # --noreload disables Django's file-watcher subprocess (cleaner in cmd).
|
|
|
|
|
+ $runCmd = "`"$SpecVenv`" manage.py runserver 0.0.0.0:$specPort --noreload"
|
|
|
|
|
+ Start-Process "cmd.exe" `
|
|
|
|
|
+ -ArgumentList "/k title LF-MRI Spectrometer && $runCmd" `
|
|
|
-WorkingDirectory $SpecDir `
|
|
-WorkingDirectory $SpecDir `
|
|
|
-WindowStyle Normal
|
|
-WindowStyle Normal
|
|
|
- Write-OK "Spectrometer started in new window (port $specPort)"
|
|
|
|
|
|
|
+ Write-OK "Spectrometer started (window: 'LF-MRI Spectrometer', port $specPort)"
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|