|
|
|
@@ -157,23 +157,36 @@ if($RunMigrations){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Write-Host "Starting IIS site $SiteName and app pool $AppPool" |
|
|
|
if((Get-WebAppPoolState -Name $AppPool).Value -eq 'Started'){ |
|
|
|
Restart-WebAppPool -Name $AppPool |
|
|
|
} else { |
|
|
|
Start-WebAppPool -Name $AppPool |
|
|
|
} |
|
|
|
Start-Website $SiteName |
|
|
|
# Start-WebAppPool/Start-Website are no-ops (no error) if already started, so there's no |
|
|
|
# need to check current state first - and checking first (via Get-WebAppPoolState) is what |
|
|
|
# was silently killing this whole block: with $ErrorActionPreference = 'Stop', a transient |
|
|
|
# error from that check (e.g. right after Wait-AppPoolFullyStopped had to force-kill a |
|
|
|
# lingering worker process) aborted the script before the admin site/pool were ever started. |
|
|
|
# Each start below is independently wrapped so a problem with one site doesn't prevent the |
|
|
|
# other from starting, and every failure is reported instead of aborting silently. |
|
|
|
function Start-SiteAndPool { |
|
|
|
param([string]$PoolName, [string]$WebsiteName) |
|
|
|
|
|
|
|
if(![string]::IsNullOrWhiteSpace($PoolName)){ |
|
|
|
try { |
|
|
|
Start-WebAppPool -Name $PoolName -ErrorAction Stop |
|
|
|
Write-Host "Started app pool $PoolName" |
|
|
|
} catch { |
|
|
|
Write-Host "WARNING: failed to start app pool $PoolName : $($_.Exception.Message)" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(![string]::IsNullOrWhiteSpace($AdminSiteName)){ |
|
|
|
if(![string]::IsNullOrWhiteSpace($AdminAppPool)){ |
|
|
|
if((Get-WebAppPoolState -Name $AdminAppPool).Value -eq 'Started'){ |
|
|
|
Restart-WebAppPool -Name $AdminAppPool |
|
|
|
} else { |
|
|
|
Start-WebAppPool -Name $AdminAppPool |
|
|
|
if(![string]::IsNullOrWhiteSpace($WebsiteName)){ |
|
|
|
try { |
|
|
|
Start-Website -Name $WebsiteName -ErrorAction Stop |
|
|
|
Write-Host "Started site $WebsiteName" |
|
|
|
} catch { |
|
|
|
Write-Host "WARNING: failed to start site $WebsiteName : $($_.Exception.Message)" |
|
|
|
} |
|
|
|
} |
|
|
|
Start-Website $AdminSiteName |
|
|
|
} |
|
|
|
|
|
|
|
Start-SiteAndPool -PoolName $AppPool -WebsiteName $SiteName |
|
|
|
Start-SiteAndPool -PoolName $AdminAppPool -WebsiteName $AdminSiteName |
|
|
|
|
|
|
|
Write-Host 'Remote apply complete.' |