Skip to content

Commit

Permalink
Merged PR 1739: update from gh for log streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfrancoislarente committed Nov 15, 2019
2 parents fdf57ff + 005af71 commit e3bda13
Show file tree
Hide file tree
Showing 20 changed files with 1,449 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

## November 2019

- [Added] New **optional** `ENTRYPOINT` scripts (log streaming, auto start watch and auto start remote debugger) for IIS based images. See [README.md](/README.md#optional-entrypoint-scripts) on how to use.
- [Added] Windows 1909 is now also supported. You can override which platforms you want by setting the parameter `AutoGenerateWindowsVersionTags` when calling `Invoke-Build`, default value is: `"1909", "1903", "ltsc2019"`.

## October 2019

- [Added] Sitecore 9.2.0 XC images.
- [Added] New 9.2.0 `xp-xconnect-processingengine` images. See [#84](https://github.com/Sitecore/docker-images/issues/43). Thanks [@adoprog](https://github.com/adoprog) :+1:
- [Added] New 9.2.0 `xp-xconnect-processingengine` images. See [#43](https://github.com/Sitecore/docker-images/issues/43). Thanks [@adoprog](https://github.com/adoprog) :+1:
- [Changed] Windows and Linux `spe` "Sitecore PowerShell Extensions" images updated to **v6.0**, indirectly *also* updating all `sxa` images. See [#84](https://github.com/Sitecore/docker-images/issues/84). Thanks [@michaellwest](https://github.com/michaellwest) :+1:
- [Changed] The `c:\tools\scripts\Watch-Directory.ps1` no longer deletes destination directories, only files. See [#89](https://github.com/Sitecore/docker-images/issues/89). Thanks [@sshushliapin](https://github.com/sshushliapin) :+1:
- [Fixed] The `c:\tools` folder was empty.
Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This will:
When completed:

1. Place your Sitecore license file at `C:\license\license.xml`, or override location using the environment variable `LICENSE_PATH` like so: `$env:LICENSE_PATH="D:\my\sitecore\licenses"`
1. Switch directory to .\windows\tests\9.x.x\ Then run any of the docker-compose files, for example an XM with: `docker-compose --file .\docker-compose.xm.yml up`
1. Switch directory to `.\windows\tests\9.x.x\` and then run any of the docker-compose files, for example an XM with: `docker-compose --file .\docker-compose.xm.yml up`

### Setting up automated builds

Expand Down Expand Up @@ -132,3 +132,27 @@ SitecoreImageBuilder\Invoke-Build `
-Registry $registry `
-Tags $tags
```

### Optional ENTRYPOINT scripts

For IIS based images (such as the roles `cm`, `standalone` and `cd`) we now have a few scripts that can be used as `ENTRYPOINT` for development and production use.

Using these `ENTRYPOINT` scripts enables you to observe Sitecore log entries in the `STDOUT` of containers in the foreground or by using commands such as `docker container logs` or `docker container attach`.

`C:\tools\entrypoints\iis\Production.ps1` features:

- Adds an UDP appender to all default log4net loggers.
- Starts `ServiceMonitor.exe` in the background.
- Starts `filebeat.exe` in the foreground and outputting to `STDOUT`.
- FileBeat inputs configured:
- IIS access logs, **disabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED=true`
- IIS error logs, **disabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED=true`
- Sitecore logs, **enabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED=false`

`C:\tools\entrypoints\iis\Development.ps1` features:

- Same as `Production.ps1`.
- Starts the Visual Studio Remote Debugger `msvsmon.exe` in the background **if** the Visual Studio Remote Debugger directory is mounted into `C:\remote_debugger`.
- Starts the `Watch-Directory.ps1` script in the background **if** a directory is mounted into `C:\src`.

See the `cm` and `cd` service in [windows/tests/9.x.x/docker-compose.xm.yml](windows/tests/9.x.x/docker-compose.xm.yml) for configuration examples.
10 changes: 8 additions & 2 deletions windows/9.0.2/sitecore-assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN New-Item -Path 'C:\\downloads' -ItemType 'Directory' -Force | Out-Null; `
& curl.exe -sS -L -o c:\\downloads\\nuget.exe https://dist.nuget.org/win-x86-commandline/v5.2.0/nuget.exe; `
& curl.exe -sS -L -o C:\\downloads\\urlrewrite.msi https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi; `
& curl.exe -sS -L -o C:\\downloads\\vc_redist.exe https://aka.ms/vs/15/release/VC_redist.x64.exe; `
& curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe;
& curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; `
& curl.exe -sS -L -o C:\\downloads\\filebeat.zip https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.1-windows-x86_64.zip;

# copy local assets
COPY *.zip C:\\downloads\\
Expand All @@ -31,6 +32,11 @@ RUN & 'C:\\install\\tools\\bin\\nuget.exe' install 'Microsoft.Web.Xdt' -Version
Copy-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\lib\\netstandard2.0\\*.dll' -Destination 'C:\\install\\tools\\bin'; `
Remove-Item -Path (Get-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\').FullName -Recurse -Force;

# extract filebeat
RUN Expand-Archive -Path 'C:\\downloads\\filebeat.zip' -DestinationPath 'C:\\install\\tools\\bin' -Force; `
Rename-Item -Path (Get-Item -Path 'C:\\install\\tools\\bin\\filebeat*windows*').FullName -NewName "filebeat"; `
Remove-Item -Path 'C:\\downloads\\filebeat.zip' -Force;

# extract assets, skip wdps, move already extracted wdps
RUN $zips = Get-ChildItem -Path 'C:\\downloads\\*.zip' -Exclude '*.scwdp.zip'; `
$zips | ForEach-Object { `
Expand All @@ -46,7 +52,7 @@ RUN New-Item -Path 'C:\\install\\setup' -ItemType 'Directory' -Force | Out-Null;
Get-ChildItem 'C:\\downloads\\*.*' -Include '*.exe', '*.msi' | Move-Item -Destination 'C:\\install\\setup';

# add tools folder
COPY tools C:\\install\\tools
COPY tools\\ C:\\install\\tools\\

FROM $BASE_IMAGE

Expand Down
163 changes: 163 additions & 0 deletions windows/9.0.2/sitecore-assets/entrypoints/iis/Development.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# setup
$ErrorActionPreference = "STOP"

Import-Module WebAdministration

function Wait-WebItemState
{
param(
[ValidateNotNullOrEmpty()]
[string]$IISPath
,
[ValidateSet("Started", "Stopped")]
[string]$State
)

while ($true)
{
Write-Host "### Waiting on item '$IISPath' state to be '$State'..."

try
{
$item = Get-Item -Path $IISPath

if ($null -ne $item -and $item.State -ne $State)
{
if ($State -eq "Started")
{
$item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue"
}
elseif ($State -eq "Stopped")
{
$item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue"
}
}
}
catch
{
$item = $null
}

if ($null -ne $item -and $item.State -eq $State)
{
Write-Host "### Waiting on item '$IISPath' completed."

break
}

Start-Sleep -Milliseconds 500
}
}

# print start message
Write-Host ("### Sitecore Development ENTRYPOINT, starting...")

# wait for w3wp to stop
while ($true)
{
$processName = "w3wp"

Write-Host "### Waiting for process '$processName' to stop..."

$running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0

if ($running)
{
Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue"
}
else
{
Write-Host "### Process '$processName' stopped..."

break;
}

Start-Sleep -Milliseconds 500
}

# wait for application pool to stop
Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped"

# check to see if we should start the msvsmon.exe
$useVsDebugger = (Test-Path -Path "C:\remote_debugger\x64\msvsmon.exe" -PathType "Leaf") -eq $true

if ($useVsDebugger)
{
# start msvsmon.exe in background
& "C:\remote_debugger\x64\msvsmon.exe" /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646

Write-Host ("### Started 'msvsmon.exe'.")
}
else
{
Write-Host ("### Skipping start of 'msvsmon.exe', to enable you should mount the Visual Studio Remote Debugger directory into 'C:\remote_debugger'.")
}

# check to see if we should start the Watch-Directory.ps1 script
$useWatchDirectory = (Test-Path -Path "C:\src" -PathType "Container") -eq $true

if ($useWatchDirectory)
{
# start Watch-Directory.ps1 in background, kill foreground process if it fails
Start-Job -Name "WatchDirectory.ps1" {
try
{
# TODO: Handle additional Watch-Directory params, use param splattering?

& "C:\tools\scripts\Watch-Directory.ps1" -Path "C:\src" -Destination "C:\inetpub\wwwroot" -ExcludeFiles "Web.config"
}
finally
{
Get-Process -Name "filebeat" | Stop-Process -Force
}
} | ForEach-Object {
Write-Host ("### Started '$($_.Name)'.")
}
}
else
{
Write-Host ("### Skipping start of 'WatchDirectory.ps1', to enable you should mount a directory into 'C:\src'.")
}

# inject Sitecore config files
Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include"

# start ServiceMonitor.exe in background, kill foreground process if it fails
Start-Job -Name "ServiceMonitor.exe" {
try
{
& "C:\ServiceMonitor.exe" "w3svc"
}
finally
{
Get-Process -Name "filebeat" | Stop-Process -Force
}
} | Out-Null

# wait for the ServiceMonitor.exe process is running
while ($true)
{
$processName = "ServiceMonitor"

Write-Host "### Waiting for process '$processName' to start..."

$running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1

if ($running)
{
Write-Host "### Process '$processName' started..."

break;
}

Start-Sleep -Milliseconds 500
}

# wait for application pool to start
Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started"

# print ready message
Write-Host ("### Sitecore ready!")

# start filebeat.exe in foreground
& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml")
Loading

0 comments on commit e3bda13

Please sign in to comment.