사이트를 끄고 파일을 배포하며 사이트를 다시 켤 수있는 배치 스크립트가 있습니다.
- 응용 프로그램 풀 중지-작동
- 웹 사이트 중지-작동
- 파일 배포-작동
- 응용 프로그램 풀 시작-가끔 만 작동합니다!
- 웹 사이트를 시작하십시오-이전에 작동하면 작동합니다
Windows Server 2012 R2를 실행 중이며 배치 스크립트는 Octopus Deploy 촉수에 의해 실행됩니다.
실패한 줄은 다음과 같습니다.
Start-WebAppPool -Name $appPoolName
$ appPoolName은 live.website.com입니다.
이 라인은 때때로 작동하지만 다른 라인에서는 작동하지 않으며 어떤 패턴에서도 일관성이 없습니다.
다른 서버에서 동일한 스크립트를 사용하고 있습니다. 응용 프로그램 정보 서비스가 실행되고 있고 제대로 실행되고 있는지 확인했습니다. 이벤트 뷰어에 시스템 로그가 없습니다.
비록 Start-WebAppPool이 호출 될 때 발생하는이 하나의 응용 프로그램 오류가 있습니다.
ERROR + Start-WebAppPool -Name $appPoolName
ERROR start-webitem : The service cannot accept control messages at this time.
왜 이런 일이 일어날 수 있는지 아는 사람이 있습니까? “시작됨”상태가 될 때까지 do-while 루프를 작성하려고했지만 영원히 실패합니다.
최신 정보
응용 프로그램 풀을 끄면 프로세스가 중지되지 않습니다.
응용 프로그램 풀을 중지 한 후에 프로세스가 계속 실행되는 이유는 무엇입니까? 말 그대로 멈추지 않고 계속 실행됩니다.
결정된!
따라서 아래 주석에 따라 응용 프로그램 풀을 중지하면 이제 스크립트를 계속하기 전에 완전히 중지 된 상태인지 확인합니다.
이것은 내가 가지고 있고 완전히 작동하는 스크립트입니다.
# Load IIS module:
Import-Module WebAdministration
# Get AppPool Name
$appPoolName = $OctopusParameters['appPoolName']
if ( (Get-WebAppPoolState -Name $appPoolName).Value -eq "Stopped" )
{
Write-Host "AppPool already stopped: " + $appPoolName
}
else
{
Write-Host "Shutting down the AppPool: " + $appPoolName
Write-Host (Get-WebAppPoolState $appPoolName).Value
# Signal to stop.
Stop-WebAppPool -Name $appPoolName
}
do
{
Write-Host (Get-WebAppPoolState $appPoolName).Value
Start-Sleep -Seconds 1
}
until ( (Get-WebAppPoolState -Name $appPoolName).Value -eq "Stopped" )
답변
Octopus Deploy에는 커뮤니티 PowerShell 스크립트가 있습니다. https://library.octopus.com/listing
다음 중 하나의 내용으로 재 시도됩니다.
# Load IIS module:
Import-Module WebAdministration
# Get AppPool Name
$appPoolName = $OctopusParameters['appPoolName']
# Get the number of retries
$retries = $OctopusParameters['appPoolCheckRetries']
# Get the number of attempts
$delay = $OctopusParameters['appPoolCheckDelay']
# Check if exists
if(Test-Path IIS:\AppPools\$appPoolName) {
# Stop App Pool if not already stopped
if ((Get-WebAppPoolState $appPoolName).Value -ne "Stopped") {
Write-Output "Stopping IIS app pool $appPoolName"
Stop-WebAppPool $appPoolName
$state = (Get-WebAppPoolState $appPoolName).Value
$counter = 1
# Wait for the app pool to the "Stopped" before proceeding
do{
$state = (Get-WebAppPoolState $appPoolName).Value
Write-Output "$counter/$retries Waiting for IIS app pool $appPoolName to shut down completely. Current status: $state"
$counter++
Start-Sleep -Milliseconds $delay
}
while($state -ne "Stopped" -and $counter -le $retries)
# Throw an error if the app pool is not stopped
if($counter -gt $retries) {
throw "Could not shut down IIS app pool $appPoolName. `nTry to increase the number of retries ($retries) or delay between attempts ($delay milliseconds)." }
}
else {
Write-Output "$appPoolName already Stopped"
}
}
else {
Write-Output "IIS app pool $appPoolName doesn't exist"
}
이 라이브러리 템플릿에서 제공되는 것은 https://library.octopus.com/step-templates/3aaf34a5-90eb-4ea1-95db-15ec93c1e54d/actiontemplate-iis-apppool-stop