worker prints start success but no attachment yet

This commit is contained in:
Nathan
2025-12-17 16:32:39 -07:00
parent 4628fafc79
commit 0460865ebc
10 changed files with 7160 additions and 45 deletions

View File

@@ -65,7 +65,7 @@ $controllerPath = Join-Path $dataRoot 'controller.ps1'
[IO.File]::WriteAllBytes($controllerPath, [Convert]::FromBase64String('{controllerBase64}'))
";
await _sshService.ExecuteRemoteCommandAsync(worker, $"powershell -NoLogo -NoProfile -NonInteractive -OutputFormat Text -ExecutionPolicy Bypass -EncodedCommand {Convert.ToBase64String(Encoding.Unicode.GetBytes(script))}");
await _sshService.ExecuteRemoteScriptAsync(worker, script);
}
public async Task DeployAttachHelperAsync(WorkerConfig worker)
@@ -79,7 +79,7 @@ $attachPath = Join-Path $dataRoot 'attach-helper.ps1'
[IO.File]::WriteAllBytes($attachPath, [Convert]::FromBase64String('{helperBase64}'))
";
await _sshService.ExecuteRemoteCommandAsync(worker, $"powershell -NoLogo -NoProfile -NonInteractive -OutputFormat Text -ExecutionPolicy Bypass -EncodedCommand {Convert.ToBase64String(Encoding.Unicode.GetBytes(script))}");
await _sshService.ExecuteRemoteScriptAsync(worker, script);
}
public string GenerateSheepItPayload(WorkerConfig worker)
@@ -171,7 +171,10 @@ catch {{
if (worker.WorkerTypes.Flamenco == null)
throw new InvalidOperationException("Worker does not have Flamenco configuration");
var config = _configService.Load();
var flamenco = worker.WorkerTypes.Flamenco;
var globalSettings = config.GlobalSettings;
var workerPath = globalSettings.FlamencoWorkerPath.Replace("'", "''");
var drives = string.Join(", ", Array.ConvertAll(flamenco.NetworkDrives.ToArray(), d => $"'{d}'"));
var paths = string.Join(", ", Array.ConvertAll(flamenco.NetworkPaths.ToArray(), p => $"'{p.Replace("\\", "\\\\")}'"));
@@ -200,7 +203,7 @@ try {{
# Start worker
Write-Host ""Starting Flamenco worker..."" -ForegroundColor Cyan
Set-Location '{flamenco.WorkerPath}'
Set-Location '{workerPath}'
if (Test-Path 'flamenco-worker.exe') {{
Write-Host ""Running flamenco-worker.exe..."" -ForegroundColor Green
$workerProcess = Start-Process -FilePath '.\flamenco-worker.exe' -NoNewWindow -PassThru -Wait
@@ -208,8 +211,8 @@ try {{
Write-Host ""Flamenco worker process has terminated with exit code: $exitCode"" -ForegroundColor Yellow
exit $exitCode
}} else {{
Write-Host ""Error: flamenco-worker.exe not found in {flamenco.WorkerPath}"" -ForegroundColor Red
[Console]::Error.WriteLine(""Error: flamenco-worker.exe not found in {flamenco.WorkerPath}"")
Write-Host ""Error: flamenco-worker.exe not found in {workerPath}"" -ForegroundColor Red
[Console]::Error.WriteLine(""Error: flamenco-worker.exe not found in {workerPath}"")
exit 1
}}
}}
@@ -327,7 +330,8 @@ if ($shouldStart) {{
}}
";
await _sshService.ExecuteRemoteCommandAsync(worker, $"powershell -NoLogo -NoProfile -NonInteractive -OutputFormat Text -ExecutionPolicy Bypass -EncodedCommand {Convert.ToBase64String(Encoding.Unicode.GetBytes(ensureScript))}");
// Pipe script through stdin to avoid command line length limits
await _sshService.ExecuteRemoteScriptAsync(worker, ensureScript);
}
public async Task StopWorkerAsync(WorkerConfig worker, string workerType)