AWS CodeDeploy Windows System. Я столкнулся с этим на 2012R2.
Задача - деплоймент веб-приложения в IIS в определенный пул. Мне нужно остановить IIS, удалить приложение, убить каталог со всем содержимым но оставив сам каталог потому что на него навешаны права и заново их вешать не хочется. Далее нужно скопировать файлы приложения в каталог, сконвертировать каталог в приложение, запустить IIS.
Из командной строки всё работает отлично. Из CodeDeploy не работает хоть убей!
Получаю что-то типа:
[stderr]New-Item : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving
stderr]the COM class factory for component with CLSID
[stderr]{688EEEE5-6A7E-422F-B2E1-***********} failed due to the following error:
[stdout]creating new website
[stderr]80040154 Class not registered (Exception from HRESULT: 0x80040154
[stderr](REGDB_E_CLASSNOTREG)).
Ну и так далее...
Беда в том, что CodeDeploy сделан на Ruby, и запускается оно как 32-битное приложение а винда у меня 64 бит и powershell должен работать с моими скриптами именно 64-битной версии а не 32-х как это получается при запуске через CodeDeploy Agent.
Делаем так - в каждый скрипт PS1 в начало добавляем то, что Амазон рекомендует и это работает:
# Are you running in 32-bit mode?
# (\SysWOW64\ = 32-bit mode)
if ($PSHOME -like "*SysWOW64*")
{
Write-Warning "Restarting this script under 64-bit Windows PowerShell."
# Restart this script under 64-bit Windows PowerShell.
# (\SysNative\ redirects to \System32\ for 64-bit mode)
& (Join-Path ($PSHOME -replace "SysWOW64", "SysNative") powershell.exe) -File `
(Join-Path $PSScriptRoot $MyInvocation.MyCommand) @args
# Exit 32-bit script.
Exit $LastExitCode
}
# Was restart successful?
Write-Warning "Hello from $PSHOME"
Write-Warning " (\SysWOW64\ = 32-bit mode, \System32\ = 64-bit mode)"
Write-Warning "Original arguments (if any): $args"
# Your 64-bit script code follows here...
#
Import-Module WebAdministration;
ConvertTo-WebApplication -PSPath 'IIS:\Sites\Default Web Site\public_logos' -ApplicationPool 'MY ASP Applications'
Вот теперь всё получится как ожидается.
В добавку варианты файлов CD:
appspec.yml:
version: 0.0
os: windows
files:
- source: public_logos\
destination: C:\Websites\public_logos
hooks:
BeforeInstall:
- location: CodeDeploy\beforeinstall.bat
timeout: 900
- location: CodeDeploy\beforeinstall.ps1
timeout: 900
AfterInstall:
- location: CodeDeploy\afterinstall.bat
timeout: 900
- location: CodeDeploy\afterinstall.ps1
timeout: 900
Beforeinstall.bat:
%systemroot%\system32\inetsrv\APPCMD stop sites "Default Web Site"
iisreset /stop
pushd C:\Websites\public_logos
rmdir /s /q C:\Websites\public_logos
exit 0
Оригинал здесь:
Windows PowerShell scripts fail to use the 64-bit version of Windows PowerShell by default
Задача - деплоймент веб-приложения в IIS в определенный пул. Мне нужно остановить IIS, удалить приложение, убить каталог со всем содержимым но оставив сам каталог потому что на него навешаны права и заново их вешать не хочется. Далее нужно скопировать файлы приложения в каталог, сконвертировать каталог в приложение, запустить IIS.
Из командной строки всё работает отлично. Из CodeDeploy не работает хоть убей!
Получаю что-то типа:
[stderr]New-Item : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving
stderr]the COM class factory for component with CLSID
[stderr]{688EEEE5-6A7E-422F-B2E1-***********} failed due to the following error:
[stdout]creating new website
[stderr]80040154 Class not registered (Exception from HRESULT: 0x80040154
[stderr](REGDB_E_CLASSNOTREG)).
Ну и так далее...
Беда в том, что CodeDeploy сделан на Ruby, и запускается оно как 32-битное приложение а винда у меня 64 бит и powershell должен работать с моими скриптами именно 64-битной версии а не 32-х как это получается при запуске через CodeDeploy Agent.
Делаем так - в каждый скрипт PS1 в начало добавляем то, что Амазон рекомендует и это работает:
# Are you running in 32-bit mode?
# (\SysWOW64\ = 32-bit mode)
if ($PSHOME -like "*SysWOW64*")
{
Write-Warning "Restarting this script under 64-bit Windows PowerShell."
# Restart this script under 64-bit Windows PowerShell.
# (\SysNative\ redirects to \System32\ for 64-bit mode)
& (Join-Path ($PSHOME -replace "SysWOW64", "SysNative") powershell.exe) -File `
(Join-Path $PSScriptRoot $MyInvocation.MyCommand) @args
# Exit 32-bit script.
Exit $LastExitCode
}
# Was restart successful?
Write-Warning "Hello from $PSHOME"
Write-Warning " (\SysWOW64\ = 32-bit mode, \System32\ = 64-bit mode)"
Write-Warning "Original arguments (if any): $args"
# Your 64-bit script code follows here...
#
Import-Module WebAdministration;
ConvertTo-WebApplication -PSPath 'IIS:\Sites\Default Web Site\public_logos' -ApplicationPool 'MY ASP Applications'
Вот теперь всё получится как ожидается.
В добавку варианты файлов CD:
appspec.yml:
version: 0.0
os: windows
files:
- source: public_logos\
destination: C:\Websites\public_logos
hooks:
BeforeInstall:
- location: CodeDeploy\beforeinstall.bat
timeout: 900
- location: CodeDeploy\beforeinstall.ps1
timeout: 900
AfterInstall:
- location: CodeDeploy\afterinstall.bat
timeout: 900
- location: CodeDeploy\afterinstall.ps1
timeout: 900
Beforeinstall.bat:
%systemroot%\system32\inetsrv\APPCMD stop sites "Default Web Site"
iisreset /stop
pushd C:\Websites\public_logos
rmdir /s /q C:\Websites\public_logos
exit 0
beforeinstall.ps1 :
# Are you running in 32-bit mode?
# (\SysWOW64\ = 32-bit mode)
if ($PSHOME -like "*SysWOW64*")
{
Write-Warning "Restarting this script under 64-bit Windows PowerShell."
# Restart this script under 64-bit Windows PowerShell.
# (\SysNative\ redirects to \System32\ for 64-bit mode)
& (Join-Path ($PSHOME -replace "SysWOW64", "SysNative") powershell.exe) -File `
(Join-Path $PSScriptRoot $MyInvocation.MyCommand) @args
# Exit 32-bit script.
Exit $LastExitCode
}
# Was restart successful?
Write-Warning "Hello from $PSHOME"
Write-Warning " (\SysWOW64\ = 32-bit mode, \System32\ = 64-bit mode)"
Write-Warning "Original arguments (if any): $args"
# Your 64-bit script code follows here...
#
Import-Module WebAdministration
Remove-WebApplication -Name public_logos -Site 'Default Web Site'
Оригинал здесь:
Windows PowerShell scripts fail to use the 64-bit version of Windows PowerShell by default
Комментариев нет:
Отправить комментарий