Gate endpoint UI refresh on fresh telemetry and land endpoint agent
A command reaching 'succeeded' only proves the agent ran the action, not that it posted a new telemetry snapshot. Reloading panels on command success alone re-rendered stale service/process rows, so a stopped process could still show running right after Refresh Status. Add a lightweight telemetrymeta probe exposing lastreportedat and gate both the header Refresh Status action and inline row Start/Stop on that stamp advancing past a pre-action baseline. Polling is bounded so an offline or idle agent never hangs the button, and messaging distinguishes a confirmed refresh from a queued one. Bring the .NET endpoint agent source (service, tray, installer) into the repo so Cameron can merge and test, with an agent/.gitignore keeping bin/obj/publish out. Includes the DncMain launch-path fix, tray single-file host env scrub, and best-effort file logger.
This commit is contained in:
@@ -87,7 +87,11 @@ $ErrorActionPreference = 'Stop'
|
||||
# =============================================================================
|
||||
|
||||
$LocalStageRoot = Join-Path $env:ProgramData 'ShopDB\intake'
|
||||
$NetworkStoreRoot = '\\wi001dataaege.wlm.geaerospace.net\shared\TEAMSYS\.sfscripts\shopdb'
|
||||
# Ship blank so a site that has not configured its share keeps everything local
|
||||
# instead of publishing to another site's path. Set this to your own share (or
|
||||
# pass -PublishRoot), e.g. '\\fileserver\shopdb$\intake'. The download endpoint
|
||||
# fills this in from asset_import_csv_location when the site has set it.
|
||||
$NetworkStoreRoot = ''
|
||||
|
||||
# Resolve effective destinations (command-line params win over CONFIG above).
|
||||
if (-not $OutputRoot) { $OutputRoot = $LocalStageRoot }
|
||||
@@ -531,9 +535,57 @@ if ($PublishRoot) {
|
||||
Write-Host ' WARNING: publishing while elevated. Network writes should run as the standard user.' -ForegroundColor Yellow
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $PublishRoot)) { New-Item -ItemType Directory -Path $PublishRoot -Force | Out-Null }
|
||||
Copy-Item -Path (Join-Path $OutputRoot '*') -Destination $PublishRoot -Recurse -Force
|
||||
Write-Host ''
|
||||
Write-Host (' Published store to: ' + $PublishRoot) -ForegroundColor Green
|
||||
|
||||
# Merge THIS PC's rows into the shared store rather than overwriting it. A
|
||||
# blind copy would erase every other PC's rows (issue: the store is meant to
|
||||
# accumulate site-wide). Merge-CsvStore upserts field-by-field, so a second
|
||||
# PC's run adds its rows and refreshes shared ones without dropping the rest.
|
||||
# A lock file serializes concurrent publishers so two PCs cannot read-modify-
|
||||
# write the same store CSV at once and lose each other's rows.
|
||||
$lockPath = Join-Path $PublishRoot '.publish.lock'
|
||||
$lockStream = $null
|
||||
for ($attempt = 0; $attempt -lt 60; $attempt++) {
|
||||
try {
|
||||
$lockStream = [System.IO.File]::Open(
|
||||
$lockPath, [System.IO.FileMode]::OpenOrCreate,
|
||||
[System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None)
|
||||
break
|
||||
} catch {
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
}
|
||||
if ($null -eq $lockStream) {
|
||||
Write-Host ''
|
||||
Write-Host (' WARNING: could not acquire publish lock at ' + $lockPath + '; skipping network merge.') -ForegroundColor Yellow
|
||||
} else {
|
||||
try {
|
||||
foreach ($fileName in $script:Stores.Keys) {
|
||||
$spec = $script:Stores[$fileName]
|
||||
$localPath = Join-Path $OutputRoot $fileName
|
||||
if (-not (Test-Path -LiteralPath $localPath)) { continue }
|
||||
$localRows = @(Import-Csv -LiteralPath $localPath)
|
||||
if ($localRows.Count -eq 0) { continue }
|
||||
$sharePath = Join-Path $PublishRoot $fileName
|
||||
$n = Merge-CsvStore -Path $sharePath -Header $spec.header -Key $spec.key -IncomingRows $localRows
|
||||
Write-Host (' merged ' + $n + ' row(s) into ' + $fileName + ' on share') -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
# Sidecars are uniquely named per asset, so a straight copy is safe and
|
||||
# nothing is overwritten across PCs.
|
||||
$localSidecars = Join-Path $OutputRoot 'sidecars'
|
||||
if (Test-Path -LiteralPath $localSidecars) {
|
||||
$shareSidecars = Join-Path $PublishRoot 'sidecars'
|
||||
if (-not (Test-Path -LiteralPath $shareSidecars)) { New-Item -ItemType Directory -Path $shareSidecars -Force | Out-Null }
|
||||
Copy-Item -Path (Join-Path $localSidecars '*') -Destination $shareSidecars -Recurse -Force
|
||||
}
|
||||
} finally {
|
||||
$lockStream.Close()
|
||||
$lockStream.Dispose()
|
||||
Remove-Item -LiteralPath $lockPath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Host ''
|
||||
Write-Host (' Published store to: ' + $PublishRoot) -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ''
|
||||
|
||||
Reference in New Issue
Block a user