fix opt 6 exit not working

also continue fix attempt on sheepit not starting
This commit is contained in:
Nathan
2025-12-02 12:07:26 -07:00
parent 18683b4ad0
commit e568e02cdf
4 changed files with 5209 additions and 1532 deletions

View File

@@ -402,8 +402,11 @@ New-Item -ItemType Directory -Path `$logsRoot -Force | Out-Null
New-Item -ItemType Directory -Path `$stateRoot -Force | Out-Null
`$logPath = Join-Path `$logsRoot 'worker.log'
`$commandPath = Join-Path `$stateRoot 'commands.txt'
`$payloadPath = Join-Path `$stateRoot 'payload.ps1'
`$payloadBase64Path = Join-Path `$stateRoot 'payload.b64'
if (-not (Test-Path `$logPath)) { New-Item -Path `$logPath -ItemType File -Force | Out-Null }
if (-not (Test-Path `$commandPath)) { New-Item -Path `$commandPath -ItemType File -Force | Out-Null }
[IO.File]::WriteAllText(`$payloadBase64Path, `$payloadBase64, [System.Text.Encoding]::UTF8)
`$metaPath = Join-Path `$instanceRoot 'state\worker-info.json'
`$controllerPath = Join-Path `$dataRoot 'controller.ps1'
@@ -437,7 +440,7 @@ if (`$shouldStart) {
LastExitCode = `$null
LogPath = `$logPath
CommandPath = `$commandPath
PayloadPath = `$null
PayloadPath = `$payloadPath
UpdatedAtUtc = (Get-Date).ToUniversalTime()
} | ConvertTo-Json -Depth 5
`$initialMeta | Set-Content -Path `$metaPath -Encoding UTF8
@@ -455,7 +458,7 @@ if (`$shouldStart) {
'-File',"`$controllerPath",
'-WorkerName',"`$workerName",
'-WorkerType',"`$workerType",
'-PayloadBase64',"`$payloadBase64"
'-PayloadBase64Path',"`$payloadBase64Path"
)
Start-Process -FilePath `$psExe -ArgumentList `$controllerArgs -WindowStyle Hidden | Out-Null
@@ -767,7 +770,11 @@ while ($true) {
Write-Host "5. Quit all workers" -ForegroundColor Yellow
Write-Host "6. Exit" -ForegroundColor Yellow
$choice = Read-Host "Select option (1-3)"
$choice = Read-Host "Select option (1-6)"
if ($choice -eq '6') {
break
}
switch ($choice) {
'1' { Select-SheepItWorker }
@@ -775,7 +782,6 @@ while ($true) {
'3' { Send-SheepItCommandAll -CommandText 'pause' }
'4' { Send-SheepItCommandAll -CommandText 'resume' }
'5' { Send-SheepItCommandAll -CommandText 'quit' }
'6' { break }
default {
Write-Host "Invalid selection." -ForegroundColor Red
Start-Sleep -Seconds 1