enet-validator/scripts/session/probe_loop.ps1

21 lines
994 B
PowerShell
Raw Normal View History

[Console]::OutputEncoding = [Text.Encoding]::UTF8
$exe = "C:\Users\tonycao\work\light\enet-validator\target\release\enet-validator.exe"
$log = "$env:TEMP\opencode\probe_loop.log"
Remove-Item $log -ErrorAction SilentlyContinue
for ($i = 0; $i -lt 14; $i++) {
$ts = Get-Date -Format "HH:mm:ss"
$env:HOSTDEMO_MODE = "claimonly"
$out = & $exe hostdemo 192.168.123.1 0 2>&1 | Out-String
Add-Content -Encoding utf8 $log ("=== " + $ts + " attempt " + $i + " ===`n" + $out)
if ($out -match "CLAIM_PROBE.*PASS") {
Add-Content -Encoding utf8 $log ((Get-Date -Format "HH:mm:ss") + " CLAIM UNLOCKED - full hostdemo starting")
Remove-Item Env:\HOSTDEMO_MODE -ErrorAction SilentlyContinue
$out2 = & $exe hostdemo 192.168.123.1 30 2>&1 | Out-String
Add-Content -Encoding utf8 $log $out2
Add-Content -Encoding utf8 $log "=== full hostdemo done ==="
break
}
Start-Sleep -Seconds 300
}
Add-Content -Encoding utf8 $log "probe loop exit"