Created
February 24, 2024 04:38
-
-
Save jonanderson10/58d7c47d24612f30413c6c18d2353d57 to your computer and use it in GitHub Desktop.
ECS Windows Container Entrypoint Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script is our container entrypoint since Windows containers only get environment | |
# variables at the process level. This makes them machine level so that IIS can see them. | |
Write-Host "Stopping IIS Service (this is expected, and in anticipation of setting environment variables)..." | |
Stop-Service -Name W3SVC -Force | |
Write-Host "Starting environment variable setup..." | |
foreach($key in [System.Environment]::GetEnvironmentVariables('Process').Keys) { | |
if ([System.Environment]::GetEnvironmentVariable($key, 'Machine') -eq $null) { | |
$val = [System.Environment]::GetEnvironmentVariable($key, 'Process'); | |
try { | |
[System.Environment]::SetEnvironmentVariable($key, $val, 'Machine') | |
Write-Host "Set $key at Machine scope" | |
} catch { | |
Write-Host "Error setting $key -- $($_)" | |
} | |
} | |
} | |
# We use log monitor to get all our system and application logs to console stdout | |
C:\LogMonitor\LogMonitor.exe "C:\ServiceMonitor.exe w3svc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment