Skip to content

Commit

Permalink
Fix tracing when there are multiple self-hosted runners
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Brignull committed Sep 2, 2020
1 parent 68c6069 commit 2dbd7e8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
21 changes: 18 additions & 3 deletions lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,24 @@ export async function runInit(
[String]
$tracer
)
Get-Process -Name Runner.Worker
$process=Get-Process -Name Runner.Worker
$id=$process.Id
# Go up the process tree until finding an ancestor called "Runner.Worker.exe"
# A new Runner.Worker is spawned for each job. It is spawned by a process
# called Runner.Listener that persists for the life of the worker.
$id = $PID
while ($true) {
$p = Get-CimInstance -Class Win32_Process -Filter "ProcessId = $id"
Write-Host "Found process: $p"
if ($p -eq $null) {
throw "Could not determine Runner.Worker.exe process"
}
if ($p[0].Name -eq "Runner.Worker.exe") {
Break
} else {
$id = $p[0].ParentProcessId
}
}
Invoke-Expression "&$tracer --inject=$id"`);

await new toolrunnner.ToolRunner(
Expand Down

0 comments on commit 2dbd7e8

Please sign in to comment.