refactor(platform): harden LAB evidence and telemetry
This commit is contained in:
@@ -128,6 +128,15 @@ try {
|
||||
throw "Failed to apply the NDC service display name"
|
||||
}
|
||||
Set-Service -Name $serviceName -StartupType Automatic
|
||||
& sc.exe failure $serviceName reset= 86400 `
|
||||
actions= restart/5000/restart/30000/restart/60000 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to configure Telegraf service recovery actions"
|
||||
}
|
||||
& sc.exe failureflag $serviceName 1 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to enable Telegraf recovery for non-crash failures"
|
||||
}
|
||||
Start-Service -Name $serviceName
|
||||
$service = Get-Service -Name $serviceName
|
||||
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Running, [TimeSpan]::FromSeconds(20))
|
||||
@@ -140,6 +149,7 @@ try {
|
||||
DisplayName = $service.DisplayName
|
||||
Status = $service.Status.ToString()
|
||||
StartType = $service.StartType.ToString()
|
||||
RecoveryConfigured = $true
|
||||
Configuration = $configurationPath
|
||||
PipelineCollector = $collectorPath
|
||||
PipelineJournal = $PipelineJournal
|
||||
|
||||
@@ -118,8 +118,27 @@ try {
|
||||
[ServiceProcess.ServiceControllerStatus]::Running,
|
||||
[TimeSpan]::FromSeconds(20)
|
||||
)
|
||||
& sc.exe failure $serviceName reset= 86400 `
|
||||
actions= restart/5000/restart/30000/restart/60000 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to configure Telegraf service recovery actions"
|
||||
}
|
||||
& sc.exe failureflag $serviceName 1 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to enable Telegraf recovery for non-crash failures"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
|
||||
$service = Get-Service -Name $serviceName
|
||||
if ($service.Status -ne [ServiceProcess.ServiceControllerStatus]::Stopped) {
|
||||
$service.WaitForStatus(
|
||||
[ServiceProcess.ServiceControllerStatus]::Stopped,
|
||||
[TimeSpan]::FromSeconds(20)
|
||||
)
|
||||
}
|
||||
Set-ItemProperty -Path $serviceRegistryPath -Name Environment `
|
||||
-Type MultiString -Value $serviceEnvironmentBefore
|
||||
Copy-Item -LiteralPath $backupPath -Destination $configurationPath
|
||||
if ($hadCollector) {
|
||||
Copy-Item -LiteralPath $backupCollectorPath -Destination $collectorPath
|
||||
@@ -135,6 +154,7 @@ try {
|
||||
SchemaVersion = "missioncore.telemetry-agent-config-result/v1"
|
||||
ServiceName = $serviceName
|
||||
Status = (Get-Service -Name $serviceName).Status.ToString()
|
||||
RecoveryConfigured = $true
|
||||
Configuration = $configurationPath
|
||||
Backup = $backupPath
|
||||
PipelineCollector = $collectorPath
|
||||
|
||||
Reference in New Issue
Block a user