# Orchestrator: pousti ingest dokola; po wedgi MailStore IMAP restartne sluzbu # a zkusi znovu. Diky checkpointu kazdy pokus navaze tam, kde wedge utnul. # Konci kdyz ingest skonci ciste $env:PYTHONIOENCODING = "utf-8" $py = "U:/janssen/.venv/Scripts/python.exe" $maxAttempts = 10 $pass = ConvertTo-SecureString "Vlado7309208104++" -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential("administrator", $pass) function Restart-MailStore { Write-Output ">>> restart MailStoreServer sluzby na .53" Invoke-Command -ComputerName 192.168.1.53 -Credential $cred -ScriptBlock { Restart-Service -Name MailStoreServer -Force } Start-Sleep -Seconds 25 # pockej az IMAP zacne odpovidat (delsi warmup - obri slozky chteji zahraty server) for ($i = 1; $i -le 12; $i++) { $ok = & $py "U:/janssen/mailstore/_imap_test.py" 2>&1 | Select-String "OK za" if ($ok) { Start-Sleep -Seconds 8; Write-Output ">>> IMAP zpet"; return } Start-Sleep -Seconds 6 } Write-Output ">>> IMAP po restartu stale neodpovida (jedu dal stejne)" } for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) { Write-Output "================ POKUS $attempt / $maxAttempts ================" & $py "U:/janssen/mailstore/_run_ingest.py" $rc = $LASTEXITCODE Write-Output ">>> ingest skoncil rc=$rc" if ($rc -eq 0) { Write-Output "================ HOTOVO (cisty beh) ================" break } # wedge / chyba -> restart MailStore a zkus znovu Restart-MailStore }