Skip to content

Instantly share code, notes, and snippets.

@nate-strauser
Forked from bmccormack/churnQueue.ps1
Created April 9, 2012 21:33
Show Gist options
  • Save nate-strauser/2346682 to your computer and use it in GitHub Desktop.
Save nate-strauser/2346682 to your computer and use it in GitHub Desktop.
Churn through the Kiln Queue with restarts
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
}
@nate-strauser
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment