-
Notifications
You must be signed in to change notification settings - Fork 2
/
WaitForSitefinityToStart.ps1
65 lines (54 loc) · 1.57 KB
/
WaitForSitefinityToStart.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# url - URL of Sitefinity application
# successOuput - What message to return when application has started
# totalWaitMinutes - How long this script should wait for application to start until continuing
param([String]$url="http://localhost", [String]$successOuput="SUCCESS", [Int32]$totalWaitMinutes=10)
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()
$statusUrl = ($url + "/appstatus")
""
"Attempt to start Sitefinity up: " + $statusUrl
$retryCount = 0;
$progressPreference = 'silentlyContinue'
try
{
"Retry: " + $retryCount
$retryCount++;
$response = Invoke-WebRequest $statusUrl -TimeoutSec 1800 -UseBasicParsing
if($response.StatusCode -eq 200)
{
"Sitefinity is starting ..." + $statusUrl
}
while($response.StatusCode -eq 200)
{
"Checking Sitefinity status: " + $statusUrl
"Retry: " + $retryCount
$retryCount++;
$response = Invoke-WebRequest $statusUrl -TimeoutSec 1800 -UseBasicParsing
if($elapsed.Elapsed.Minites > $totalWaitMinutes)
{
"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)
{
"Sitefinity has started after " + $elapsed.Elapsed.Seconds + " second(s) - " + $successOuput
}
else
{
"Sitefinity failed to start"
}
}
else
{
"Sitefinity failed to start - StatusCode: " + $_.Exception.Response.StatusCode.Value__
$_|format-list
$_.Exception|format-list
}
}