Kiln »
KilnSupportScriptsPowershell Scripts to help monitor a Kiln environment. Contact Fog Creek support before using.Read More
Alias information
is an alias for .
Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
Add sleep operations to allow the server to recover from the commands. Especially useful in recovering from the exception thrown by the QueueService and automatically restarting the script. FC2295785
### Please contact Fog Creek support before running this script.###### This function will churn through the Kiln queue manually. The QueueService### should be turned off before running this script. Run this script like so:###### > . .\churnQueue.ps1### > churn-queue###### Note that this script will automatically restart the Kiln Storage Service### if it encounters an exception. This is mainly to deal with a socket ### limitation on Win 2003, but it may help in Win 2008 environments as well.functionget-queueLength(){try{$s=(New-Objectnet.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}functionchurn-queue([switch]$switchGetQueueLength){pushdcd"C:\Program Files\Kiln\queue"# We want to stop the Kiln Queuing Service because we're going to be running it# manually.write"---------------- Stopping Queuing Service ----------------"sc.exestop"Kiln Queuing Service"$continue=$true$restartKss=$false# We're going to loop until we're out of work for the queue service.while($continue){if($restartKss){# With the QueueService hammering Redis, this can cause Redis to fail at the# network level. This causes the Queuing Service to fail. Restarting the # Kiln Storage Service restarts Redis so that the Queuing Service can continue. $restartKss = $false
write "---------------- Restart Kiln Storage Service ----------------"
sc.exe stop "KilnStorageService"
+ # give the services time to clean up+ sleep 5 sc.exe start "KilnStorageService"
}
$getQueueLength = $switchGetQueueLength
# The following code is going to process the Queue Service manually, printing the# output. Powershell is then piping the output as a stream, which is tested for # various conditions to determine if the process is working.write"---------------- Churn Through Kiln Queue ----------------"..\QueueService.exe/verbose/noservice|out-string-stream|foreach{if($getQueueLength){# We'll use get-queueLength (defined above) to query the queue service # stats to see how many items we have left in the queue. This number# should go down over time. We'll query it once each time we start the # Queue Service.
$getQueueLength = $false
$queueLength = get-queueLength
+ # give the queue some time to process+ sleep 3 write "---------------- Get Kiln Queue Length ----------------"
write "KILN QUEUE LENGTH: $queueLength"
}
write$_if($_|select-string"no work"-quiet){# If there are no items left for the Queue, we'll see a message that says "no work",# at which point we'll want to exit the entire loop.write"---------------- No more Work in the Queue ----------------"$continue=$falsecontinue}if($_|select-string"Exception"-quiet){# If we see the word "Exception", this almost certainly means that Redis has crashed.# We're going set a flag to restart the Kiln Storage Service, then continue to # restart the current loop. The Storage Service will get restarted at the top of # the loop.write"---------------- Exception While Processing the Queue ----------------"$restartKss=$truecontinue} }
}
popd
-}
\ No newline at end of file +}
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.