Skip to content

Commit

Permalink
Merge pull request #7 from patrickperrone/specify-timeout
Browse files Browse the repository at this point in the history
Specify timeout, fixes #3
  • Loading branch information
patrickperrone committed Oct 22, 2015
2 parents 2ac4d6b + 42e93ed commit b810215
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 16 deletions.
2 changes: 1 addition & 1 deletion SitecoreShipFunctions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '1.0'
ModuleVersion = '1.1'

# ID used to uniquely identify this module
GUID = '1b83fbdb-f779-4cef-bbC5-b289a114eef4'
Expand Down
70 changes: 55 additions & 15 deletions SitecoreShipFunctions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ function Invoke-SitecoreShipAboutRequest
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
#>
[CmdletBinding()]
param
(
[parameter(Position=0, Mandatory=$true)]
[string]$HostName,
[parameter(Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps
[switch]$UseHttps,
[parameter(Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600
)
process
{
Expand All @@ -100,7 +105,7 @@ function Invoke-SitecoreShipAboutRequest

$servicePath = "/services/about"
$url = "{0}://{1}{2}" -f $scheme,$HostName,$servicePath
$webResponse = Invoke-WebRequest $url
$webResponse = Invoke-WebRequest $url -TimeoutSec $Timeout
return $webResponse
}
}
Expand Down Expand Up @@ -129,24 +134,29 @@ function Get-SitecoreShipVersion
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
#>
[CmdletBinding()]
param
(
[parameter(Position=0, Mandatory=$true)]
[string]$HostName,
[parameter(Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps
[switch]$UseHttps,
[parameter(Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600
)
process
{
if ($UseHttps)
{
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -UseHttps
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -UseHttps -Timeout $Timeout
}
else
{
$webResponse = Invoke-SitecoreShipAboutRequest $HostName
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -Timeout $Timeout
}
$bodyText = ($webResponse.ParsedHtml.getElementsByTagName("body") | select innerText).innerText
[string]$versionText = $bodyText.Split("`r`n") | Select-String "Current release"
Expand Down Expand Up @@ -175,26 +185,31 @@ function Test-SitecoreShipIsInstalled
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
#>
[CmdletBinding()]
param
(
[parameter(Position=0, Mandatory=$true)]
[string]$HostName,
[parameter(Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps
[switch]$UseHttps,
[parameter(Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600
)
process
{
try
{
if ($UseHttps)
{
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -UseHttps
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -UseHttps -Timeout $Timeout
}
else
{
$webResponse = Invoke-SitecoreShipAboutRequest $HostName
$webResponse = Invoke-SitecoreShipAboutRequest $HostName -Timeout $Timeout
}

if ($webResponse.StatusCode -eq 200)
Expand Down Expand Up @@ -249,6 +264,9 @@ function Invoke-SitecoreShipPackageInstallRequest
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
.PARAMETER DisableIndexing
Suspend search index updates during installation.
#>
Expand All @@ -263,11 +281,14 @@ function Invoke-SitecoreShipPackageInstallRequest
[switch]$FileUpload,
[parameter(Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps,
[parameter(Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600,
[parameter(Mandatory=$false, HelpMessage="Suspends search index updates during install; improves installation speed.")]
[switch]$DisableIndexing
)
process
{
$Timeout = $Timeout * 1000
if ($FileUpload -and !(Test-Path $FilePath))
{
throw [System.IO.FileNotFoundException] "$FilePath not found."
Expand Down Expand Up @@ -320,7 +341,8 @@ function Invoke-SitecoreShipPackageInstallRequest

# Form web request
$request = [System.Net.HttpWebRequest]::CreateHttp($serviceUrl)
$request.Method = 'POST';
$request.Method = 'POST'
$request.Timeout = $Timeout
$request.Accept = "application/json, text/javascript, */*"
$request.KeepAlive = $true
$request.ContentType = "multipart/form-data; boundary={0}" -f $boundaryId
Expand Down Expand Up @@ -384,6 +406,9 @@ function Invoke-SitecoreShipPublishRequest
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
.PARAMETER PublishMode
Accepted values are full, smart, or incremental
Expand All @@ -409,27 +434,31 @@ function Invoke-SitecoreShipPublishRequest
[parameter(Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps,

[parameter(Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600,

[parameter(ParameterSetName="mode", Position=1, Mandatory=$true, HelpMessage="Valid values are full, smart, or incremental")]
[ValidateSet("full", "smart", "incremental")]
[string]$PublishMode,

[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="TODO")]
[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="The source database.")]
[string]$PublishSource,

[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="TODO")]
[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="The target database(s).")]
[string[]]$PublishTargets,

[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="TODO")]
[parameter(ParameterSetName="mode", Mandatory=$false, HelpMessage="The languages to publish (e.g. en, da)")]
[string[]]$Languages,

[parameter(ParameterSetName="items", Mandatory=$true, HelpMessage="TODO")]
[parameter(ParameterSetName="items", Mandatory=$true, HelpMessage="JSON object that represents items to publish.")]
[string]$PublishItems,

[parameter(Mandatory=$false, HelpMessage="TODO.")]
[switch]$ResultAsUniversalTime
)
process
{
$Timeout = $Timeout * 1000
$scheme = "http"
if ($UseHttps)
{
Expand Down Expand Up @@ -474,6 +503,7 @@ function Invoke-SitecoreShipPublishRequest
# Form web request
$request = [System.Net.HttpWebRequest]::CreateHttp($serviceUrl)
$request.Method = 'POST';
$request.Timeout = $Timeout
$request.Accept = "application/json, text/javascript, */*"
$request.KeepAlive = $true
$request.ContentType = "multipart/form-data; boundary={0}" -f $boundaryId
Expand All @@ -488,7 +518,8 @@ function Invoke-SitecoreShipPublishRequest

# Form web request
$request = [System.Net.HttpWebRequest]::CreateHttp($serviceUrl)
$request.Method = 'POST';
$request.Method = 'POST'
$request.Timeout = $Timeout
$request.Accept = "application/json, text/javascript, */*"
$request.KeepAlive = $true
$request.ContentType = "application/json"
Expand Down Expand Up @@ -547,6 +578,9 @@ function Get-SitecoreShipLastCompletedPublish
.PARAMETER UseHttps
The web service request should use HTTPS to connect to the Sitecore server.
.PARAMETER Timeout
Duration in seconds before the web service request times out. The default value is 600 seconds.
.PARAMETER PublishSource
This is the name of the source database.
Expand Down Expand Up @@ -574,6 +608,12 @@ function Get-SitecoreShipLastCompletedPublish
[parameter(ParameterSetName="language", Mandatory=$false, HelpMessage="Make web service request using HTTPS scheme.")]
[switch]$UseHttps,

[parameter(ParameterSetName="base", Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[parameter(ParameterSetName="source", Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[parameter(ParameterSetName="target", Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[parameter(ParameterSetName="language", Mandatory=$false, HelpMessage="Duration to wait in seconds before timing out the request to Sitecore.Ship.")]
[int]$Timeout = 600,

[parameter(ParameterSetName="source", Mandatory=$true, HelpMessage="TODO")]
[parameter(ParameterSetName="target", Mandatory=$true, HelpMessage="TODO")]
[parameter(ParameterSetName="language", Mandatory=$true, HelpMessage="TODO")]
Expand Down Expand Up @@ -617,7 +657,7 @@ function Get-SitecoreShipLastCompletedPublish

write-host $serviceUrl

$time = Invoke-RestMethod "http://sitecoreshippoc/services/publish/lastcompleted" -Method GET
$time = Invoke-RestMethod "http://sitecoreshippoc/services/publish/lastcompleted" -Method GET -TimeoutSec $Timeout

if (!$ResultAsUniversalTime)
{
Expand Down

0 comments on commit b810215

Please sign in to comment.