Forked from sitefinitySDK/EnsureSitefinityIsRunning.ps1
Created
December 5, 2018 00:50
-
-
Save thisismyrobot/ba7fd505d1c6957f3c897d6475a58f82 to your computer and use it in GitHub Desktop.
SF_10.1, SF_10.2, SF_11.0 - https://docs.sitefinity.com/application-status-page-in-continuous-integration-scenarios
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
param([String]$url="http://localhost", [String]$successOuput="SUCCESS", [Int32]$totalWaitMinutes=10) | |
$elapsed = [System.Diagnostics.Stopwatch]::StartNew() | |
$statusUrl = ($url + "/appstatus") | |
Write-Warning ("Attempt to start Sitefinity up: " + $statusUrl) | |
$retryCount = 0; | |
try | |
{ | |
Write-Warning ("Retry: " + $retryCount) | |
$retryCount++; | |
$response = Invoke-WebRequest $statusUrl -TimeoutSec 1800 -UseBasicParsing | |
if($response.StatusCode -eq 200) | |
{ | |
Write-Warning ("Sitefinity is starting ..." + $statusUrl) | |
} | |
while($response.StatusCode -eq 200) | |
{ | |
Write-Warning ("Checking Sitefinity status: " + $statusUrl) | |
Write-Warning ("Retry: " + $retryCount) | |
$retryCount++; | |
$response = Invoke-WebRequest $statusUrl -TimeoutSec 1800 -UseBasicParsing | |
if($elapsed.Elapsed.Minites > $totalWaitMinutes) | |
{ | |
Write-Warning ("Sitefinity did NOT start in the specified maximum time") | |
break | |
} | |
Start-Sleep -s 1 | |
} | |
} | |
catch | |
{ | |
if($_.Exception.Response.StatusCode.Value__ -eq 404) | |
{ | |
$response = Invoke-WebRequest $url -TimeoutSec 120 -UseBasicParsing | |
if($response.StatusCode -eq 200) | |
{ | |
Write-Warning ("Sitefinity has started after " + $elapsed.Elapsed.Seconds + " second(s) - " + $successOuput) | |
} | |
else | |
{ | |
Write-Warning "Sitefinity failed to start" | |
} | |
} | |
else | |
{ | |
Write-Warning ("Sitefinity failed to start - StatusCode: " + $_.Exception.Response.StatusCode.Value__) | |
Write-Warning $_|format-list -force | |
Write-Warning $_.Exception|format-list -force | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment