-
-
Save nate-strauser/2346682 to your computer and use it in GitHub Desktop.
Churn through the Kiln Queue with restarts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get-queueLength(){ | |
try { | |
$s = (New-Object net.webclient).DownloadString('http://localhost:56785/stats.json') | |
} | |
catch { | |
return "queue length unavailable" | |
} | |
$queueLength = $s -split (',') | foreach{if ($_ | select-string "queueLength" -quiet){ ($_ -split ":")[1]}} | |
return $queueLength | |
} | |
$service = "Kiln Queuing Service" | |
$queueLength = get-queueLength | |
while($queueLength -gt 1){ | |
"queue length $queueLength" | |
$status = sc.exe query $service | |
$running = $status -match "RUNNING" | |
if (!$running){ | |
"service was not running - starting" | |
sc.exe start $service | |
start-sleep -s 5 | |
$status = sc.exe query $service | |
"service started" | |
$status | |
}else{ | |
"service already running" | |
} | |
start-sleep -s 15 | |
$queueLength = get-queueLength | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
seems like it processes much faster when run via the service instead of exe - however my service keeps stopping - so this more simple keep alive works well for me