Kiln »
KilnSupportScriptsPowershell Scripts to help monitor a Kiln environment. Contact Fog Creek support before using.
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.
adding .Timeout set to 300000 ms or 300s (5 mins). Any more than this and there's something else wrong with the Storage Service that needs investigation, or a slow server.
<#.SYNOPSIS Reenqueues or destroys tasks in the Kiln Queue Service.DESCRIPTION This script is similar to the old FogCreek "churn the queue" script that we had for versions of Kiln prior to 2.9.x. It simply hits the URLs that are provided via the Queue Stats page to reenqueue or destrow all failed tasks and/or all currently running tasks (since they can get stuck running sometimes). It should be used when the page at http://localhost:56785/ indicates that the queue is choking..EXAMPLE reenqueue_2.9_tasks.ps1 -retryRunning -destroyFailures This will reset everything that is currently in the queue, and permenantly destroy all failed tasks..PARAMETER qs_host The machine name where the Queue Service is running. The default value is almost always correct..PARAMETER destroyFailures Destroys all failed tasks (mutually exclusive with '-retryFailures')..PARAMETER retryFailures Retries all failed tasks (mutually exclusive with '-destroyFailures')..PARAMETER destroyRunning Destroys all currently running tasks (mutually exclusive with '-retryRunning')..PARAMETER retryRunning Retries all currently running tasks (mutually exclusive with '-destroyRunning')..NOTES Author: Quentin Schroeder Date: Dec 13, 2012#>param([string]$qs_host="localhost",[switch]$destroyFailures,[switch]$retryFailures,[switch]$destroyRunning,[switch]$retryRunning)functionmain(){if($destroyFailures-and$retryFailures){write-host"Cannot choose to both destroy AND retry failed tasks, please select only one option."exit}if($destroyRunning-and$retryRunning){write-host"Cannot choose to both destroy AND retry running tasks, please select only one option."exit}if(!($destroyRunning-or$retryRunning-or$destroyFailures-or$retryFailures)){write-host"`nNo command was selected, this script will only show the current counts of running and failed tasks in the Queue.`n"}write-host("Reading queue stats from http://{0}:56785/stats.json"-f$qs_host)$response=(New-ObjectSystem.Net.WebClient).DownloadString("http://{0}:56785/stats.json"-f$qs_host)if($?){write-host" Stats retrieved successfully.`n"}$stats=Convert-JsonToXml($response)$failures=$stats.root.failures$runningTasks=$stats.root.runningTasks$runningCount=$runningTasks.childnodes.count$failCount=$failures.childnodes.countwrite-host"Found $failCount failures..."$i=0if(($failCount-gt0)-and($destroyFailures-or$retryFailures)){foreach($failurein$failures.item){# Try both formats of the JSON (changed for 2.9.58)if($failure."#text"){$failure=$failure."#text"}elseif($failure.id."#text"){$failure=$failure.id."#text"}else{$i+=1write-host"`n$i/$failCount (NOT FOUND)..."continue}$i+=1write-host"`n$i/$failCount ($failure)..."Process-Task$qs_host$failure$destroyFailures}}write-host"`n-------`n"write-host"Found $runningCount running tasks..."$i=0if(($runningCount-gt0)-and($destroyRunning-or$retryRunning)){foreach($runningTaskin$runningTasks.item){# Try both formats of the JSON (changed for 2.9.58)if($runningTask.id."#text"){$runningTask=$runningTask.id."#text"}elseif($runningTask.hash."#text"){$runningTask=$runningTask.hash."#text"}else{$i+=1write-host"`n$i/$runningCount (NOT FOUND)..."continue}$i+=1write-host"`n$i/$runningCount ($runningTask)..."Process-Task$qs_host$runningTask$destroyRunning}}}functionProcess-Task($qs_host,$task,$destroy=$false){if(!($destroy)){write-host"Retrying task!"}$URI="http://{0}:56785/reenqueue?id={1}"-f($qs_host,$task)if($destroy){write-host"Destroying task!"$URI="http://{0}:56785/destroy?id={1}"-f($qs_host,$task)}Execute-HTTPPostCommand$URI"a=1"if(!($?)){write-host"Error!"}}# This is provided as an alternative to ConvertFrom-JSON, which requires Powershell V3# which is not on most servers by default and requires a reboot to install.# Source: (https://www.cogmotive.com/blog/powershell/parsing-json-in-powershell-xml-the-member-item-is-already-present)Add-Type-AssemblySystem.ServiceModel.Web,System.Runtime.SerializationfunctionConvert-JsonToXml([string]$json){$bytes=[byte[]][char[]]$json$quotas=[System.Xml.XmlDictionaryReaderQuotas]::Max$jsonReader=[System.Runtime.Serialization.Json.JsonReaderWriterFactory]::CreateJsonReader($bytes,$quotas)try{$xml=new-objectSystem.Xml.XmlDocument$xml.Load($jsonReader)$xml}finally{$jsonReader.Close()}}# Source: (http://stackoverflow.com/questions/5246836/user-powershell-script-to-post-to-url)functionExecute-HTTPPostCommand(){param([string]$target=$null,[string]$post=$null) $webRequest = [System.Net.WebRequest]::Create($target)
$webRequest.ContentType = "text/html"
+ $webRequest.Timeout = 300000 $PostStr = [System.Text.Encoding]::UTF8.GetBytes($post)
$webrequest.ContentLength = $PostStr.Length
$webRequest.ServicePoint.Expect100Continue = $false
$webRequest.Method="POST"$requestStream=$webRequest.GetRequestStream()$requestStream.Write($PostStr,0,$PostStr.length)$requestStream.Close()try{[System.Net.WebResponse]$resp=$webRequest.GetResponse()}catch[Net.WebException]{write-host$_.Exception.ToString()}$rs=$resp.GetResponseStream()[System.IO.StreamReader]$sr=New-ObjectSystem.IO.StreamReader-argumentList$rs[string]$results=$sr.ReadToEnd()return$results}# Do everythingmain
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.