fix for locking race #136
1 changed files with 10 additions and 4 deletions
|
|
@ -19,16 +19,22 @@ function new-lock {
|
||||||
if (Test-Path -Path $lockFile) {
|
if (Test-Path -Path $lockFile) {
|
||||||
Write-Host "Job is already running. Sleeping 10 seconds"
|
Write-Host "Job is already running. Sleeping 10 seconds"
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
New-Item -ItemType File -Path $lockFile | Out-Null
|
||||||
$lock = $false
|
$lock = $false
|
||||||
}
|
}
|
||||||
if($i -ge $timeout){
|
catch {
|
||||||
|
$lock = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($i -ge $timeout) {
|
||||||
Write-Output "Timed out"
|
Write-Output "Timed out"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
$i++
|
$i++
|
||||||
}
|
}
|
||||||
New-Item -ItemType File -Path $lockFile | Out-Null
|
|
||||||
if ($by) {
|
if ($by) {
|
||||||
$by | Out-File -FilePath $lockFile -Append
|
$by | Out-File -FilePath $lockFile -Append
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue