From 3fe1657fd63a2925eb8fd4ed97bbdb235900eed0 Mon Sep 17 00:00:00 2001 From: Roman Buryan Date: Wed, 18 Nov 2026 20:31:39 +0300 Subject: [PATCH] [PRISM] Night: export raw-night then shutdown only after successful sync --- ops/combine/research-pack/night-sprint.ps1 | 12 +++++++++++- ops/combine/research-pack/sync-to-host.ps1 | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ops/combine/research-pack/night-sprint.ps1 b/ops/combine/research-pack/night-sprint.ps1 index d34f740..4a232e0 100644 --- a/ops/combine/research-pack/night-sprint.ps1 +++ b/ops/combine/research-pack/night-sprint.ps1 @@ -1,5 +1,5 @@ param( - [switch]$Now + [switch]$Shutdown ) $ErrorActionPreference = "Continue" $base = "D:\Buryans Hub\sources\plan\research-pack" @@ -49,3 +49,13 @@ if ($ready.Count -gt 0) { Log "extractor exit $LASTEXITCODE" } Log "=== night sprint done ===" +if ($Shutdown) { + Log "export before shutdown" + & powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $base "sync-to-host.ps1") + if ($LASTEXITCODE -eq 0) { + Log "export ok; shutdown in 60s" + shutdown.exe /s /t 60 /c "Prism night sprint complete" + } else { + Log "export failed; PC stays on for manual transfer" + } +} diff --git a/ops/combine/research-pack/sync-to-host.ps1 b/ops/combine/research-pack/sync-to-host.ps1 index b880e44..1487045 100644 --- a/ops/combine/research-pack/sync-to-host.ps1 +++ b/ops/combine/research-pack/sync-to-host.ps1 @@ -6,17 +6,22 @@ $log = Join-Path $base "sync-to-host.log" function Log($m) { Add-Content -Path $log -Value "$(Get-Date -Format s) $m" } if (-not (Test-NetConnection $hostIp -Port 22 -InformationLevel Quiet -WarningAction SilentlyContinue)) { Log "host unreachable" - exit 0 + exit 1 } Log "host reachable, copying" $remote = "/tmp/prism-import" try { ssh -o BatchMode=yes -o StrictHostKeyChecking=no root@$hostIp "mkdir -p $remote" | Out-Null scp -o BatchMode=yes -o StrictHostKeyChecking=no -r (Join-Path $base "pc-results-merged-clean") "root@${hostIp}:$remote/" | Out-Null + if (Test-Path (Join-Path $base "pc-results-night")) { + scp -o BatchMode=yes -o StrictHostKeyChecking=no -r (Join-Path $base "pc-results-night") "root@${hostIp}:$remote/" | Out-Null + } scp -o BatchMode=yes -o StrictHostKeyChecking=no (Join-Path $base "yealink-current-staging.yaml") "root@${hostIp}:$remote/" | Out-Null scp -o BatchMode=yes -o StrictHostKeyChecking=no (Join-Path $base "other-vendors-staging.yaml") "root@${hostIp}:$remote/" | Out-Null - ssh -o BatchMode=yes -o StrictHostKeyChecking=no root@$hostIp "cd /root/buryan-infra; mkdir -p ops/combine/staging/ingest-pc-clean; cp $remote/yealink-current-staging.yaml $remote/other-vendors-staging.yaml ops/combine/staging/ingest-pc-clean/; /opt/work-hub/venv/bin/python ops/combine/research-pack/ingest_extracted.py --in $remote/pc-results-merged-clean --out ops/combine/staging/ingest-pc-clean >> /tmp/prism-sync.log 2>&1; echo done" | Out-Null + ssh -o BatchMode=yes -o StrictHostKeyChecking=no root@$hostIp "cd /root/buryan-infra; mkdir -p ops/combine/staging/ingest-pc-clean; cp $remote/yealink-current-staging.yaml $remote/other-vendors-staging.yaml ops/combine/staging/ingest-pc-clean/; if [ -d $remote/pc-results-night ]; then rm -rf ops/combine/staging/raw-night; cp -r $remote/pc-results-night ops/combine/staging/raw-night; fi; /opt/work-hub/venv/bin/python ops/combine/research-pack/ingest_extracted.py --in $remote/pc-results-merged-clean --out ops/combine/staging/ingest-pc-clean >> /tmp/prism-sync.log 2>&1; echo done" | Out-Null Log "ingested" + exit 0 } catch { Log "sync failed: $($_.Exception.Message)" + exit 1 }