18 lines
1023 B
PowerShell
18 lines
1023 B
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$root = 'D:\web\dj'
|
|
$exe = Join-Path $root 'HuobaoDrama\HuobaoDrama.exe'
|
|
$python = 'C:\Users\pc\AppData\Local\Programs\Python\Python311\python.exe'
|
|
& $python (Join-Path $root 'model-bridge\audit_data.py') 'restart-before.json'
|
|
$processes = @(Get-Process -Name HuobaoDrama -ErrorAction SilentlyContinue | Where-Object { $_.Path -eq $exe })
|
|
foreach ($process in $processes) { if ($process.MainWindowHandle -ne 0) { $null = $process.CloseMainWindow() } }
|
|
$deadline = (Get-Date).AddSeconds(12)
|
|
do {
|
|
$remaining = @(Get-Process -Name HuobaoDrama -ErrorAction SilentlyContinue | Where-Object { $_.Path -eq $exe })
|
|
if (-not $remaining.Count) { break }
|
|
Start-Sleep -Milliseconds 300
|
|
} while ((Get-Date) -lt $deadline)
|
|
if ($remaining.Count) { throw 'Application did not close cleanly' }
|
|
& $python (Join-Path $root 'model-bridge\start_huobao.py')
|
|
if ($LASTEXITCODE -ne 0) { throw 'Restart health check failed' }
|
|
& $python (Join-Path $root 'model-bridge\audit_data.py') 'restart-after.json'
|