система авторизации
Offline regression tests / windows (3.11) (push) Canceled after 0s
Offline regression tests / windows (3.12) (push) Canceled after 0s
Offline regression tests / windows (3.13) (push) Canceled after 0s

This commit is contained in:
listik committed 2026-10-23 21:14:57 +03:00
1 parent 85425483c0
commit f6f1ae20c2
21 files changed
+581 -110

No files matched your search

+19 -7
View File
@@ -17,7 +17,7 @@ function Server-Processes {
}
function Answers {
try { Invoke-RestMethod "$Url/api/state" -TimeoutSec 3 | Out-Null; return $true } catch { return $false }
try { Invoke-RestMethod "$Url/health" -TimeoutSec 3 | Out-Null; return $true } catch { return $false }
}
function Set-Watchdog([bool] $On) {
@@ -31,18 +31,26 @@ if ($Action -eq "stop") {
if (-not (Server-Processes)) { Write-Host "Сервер не запущен." -ForegroundColor Yellow; Set-Watchdog $false; exit 0 }
# реальная торговля: закрытие, которое идёт прямо сейчас, лучше не прерывать
try {
$real = Invoke-RestMethod "$Url/api/basis?ex=cross_real" -TimeoutSec 5
$closing = @($real.positions | Where-Object { $_.real -and $_.closing })
$open = @($real.positions | Where-Object { $_.real })
$real = Invoke-RestMethod "$Url/system/status" -TimeoutSec 20
$closing = @($real.real_positions | Where-Object { $_.closing })
$open = @($real.real_positions)
if ($closing.Count) {
Write-Host ("Сейчас закрывается реальная сделка: " + (($closing | ForEach-Object { $_.base }) -join ", ")) -ForegroundColor Red
Write-Host ("Сейчас закрываются реальные сделки: " + (($closing | ForEach-Object { $_.user + ":" + $_.coin }) -join ", ")) -ForegroundColor Red
$ans = Read-Host "Всё равно остановить? (y — да, иначе — нет)"
if ($ans -ne "y") { Write-Host "Остановка отменена."; exit 1 }
} elseif ($open.Count) {
Write-Host ("Открытые реальные сделки: " + (($open | ForEach-Object { $_.base }) -join ", ") +
Write-Host ("Открытые реальные сделки: " + (($open | ForEach-Object { $_.user + ":" + $_.coin }) -join ", ") +
" — пока сервер остановлен, за ними никто не следит; после запуска программа продолжит их вести.") -ForegroundColor Yellow
$ans = Read-Host "Остановить сервер с открытыми реальными позициями? (y — да, иначе — нет)"
if ($ans -ne "y") { Write-Host "Остановка отменена."; exit 1 }
}
} catch {}
} catch {
if (Server-Processes) {
Write-Host "Не удалось проверить открытые реальные сделки через сервер." -ForegroundColor Yellow
$ans = Read-Host "Всё равно остановить процессы? Открытые позиции временно останутся без контроля. (y — да, иначе — нет)"
if ($ans -ne "y") { Write-Host "Остановка отменена."; exit 1 }
}
}
Set-Watchdog $false
# сначала цикл перезапуска (иначе он поднимет движок), потом движок и страница
foreach ($round in 1..3) {
@@ -64,6 +72,10 @@ if ((Server-Processes) -and (Answers)) {
Start-Process $Url
exit 0
}
if (Server-Processes) {
Write-Host "Обнаружена старая версия сервера без новой авторизации. Сначала запустите ОСТАНОВИТЬ_СЕРВЕР.bat, проверьте активные позиции и подтвердите остановку; затем запустите этот файл снова." -ForegroundColor Red
exit 1
}
$VenvPython = Join-Path $Dir ".venv\Scripts\python.exe"
$haveVenv = $false
if (Test-Path -LiteralPath $VenvPython) {