Skip to content

Fixed issues when onboarding HA setup, and issues with Health Check script #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions SHIR/health-check.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
$DmgcmdPath = "C:\Program Files\Microsoft Integration Runtime\5.0\Shared\dmgcmd.exe"

function Run-Process([string] $process, [string] $arguments)
{
Write-Verbose "Run-Process: $process $arguments"

$errorFile = "$env:tmp\tmp$pid.err"
$outFile = "$env:tmp\tmp$pid.out"
"" | Out-File $outFile
"" | Out-File $errorFile

$errVariable = ""

if ([string]::IsNullOrEmpty($arguments))
{
$proc = Start-Process -FilePath $process -Wait -Passthru -NoNewWindow `
-RedirectStandardError $errorFile -RedirectStandardOutput $outFile -ErrorVariable errVariable
}
else
{
$proc = Start-Process -FilePath $process -ArgumentList $arguments -Wait -Passthru -NoNewWindow `
-RedirectStandardError $errorFile -RedirectStandardOutput $outFile -ErrorVariable errVariable
}

$errContent = [string] (Get-Content -Path $errorFile -Delimiter "!!!DoesNotExist!!!")
$outContent = [string] (Get-Content -Path $outFile -Delimiter "!!!DoesNotExist!!!")

Remove-Item $errorFile
Remove-Item $outFile

if($proc.ExitCode -ne 0 -or $errVariable -ne "")
{
Throw-Error "Failed to run process: exitCode=$($proc.ExitCode), errVariable=$errVariable, errContent=$errContent, outContent=$outContent."
}

if ([string]::IsNullOrEmpty($outContent))
{
return $outContent
}

return $outContent.Trim()
}
function Check-Node-Connection() {
Start-Process $DmgcmdPath -Wait -ArgumentList "-cgc" -RedirectStandardOutput "C:\SHIR\status-check.txt"
$ConnectionResult = Get-Content "C:\SHIR\status-check.txt"
Remove-Item -Force "C:\SHIR\status-check.txt"

$ConnectionResult = Run-Process $DmgcmdPath "-cgc"

if ($ConnectionResult -like "Connected") {
return $TRUE
Expand Down
12 changes: 5 additions & 7 deletions SHIR/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,17 @@ function RegisterNewNode {
)

Write-Log "Start registering the new SHIR node"

if ($ENABLE_HA -eq "true") {
Write-Log "Enable High Availability"
$PORT = if (!$HA_PORT) { "8060" } else { $HA_PORT }
Start-Process $DmgcmdPath -Wait -ArgumentList "-EnableRemoteAccessInContainer", "$($PORT)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
}
if (!$NODE_NAME) {
Start-Process $DmgcmdPath -Wait -ArgumentList "-RegisterNewNode", "$($AUTH_KEY)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
} else {
Start-Process $DmgcmdPath -Wait -ArgumentList "-RegisterNewNode", "$($AUTH_KEY)", "$($NODE_NAME)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
}

if ($ENABLE_HA -eq "true") {
Write-Log "Enable High Availability"
$PORT = $HA_PORT -or "8060"
Start-Process $DmgcmdPath -Wait -ArgumentList "-EnableRemoteAccess", "$($PORT)"
}

$StdOutResult = Get-Content "C:\SHIR\register-out.txt"
$StdErrResult = Get-Content "C:\SHIR\register-error.txt"

Expand Down