Harden Windows service supervision
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
$TaskNames = @("DocuTranslate", "DocuTranslateWatchdog")
|
||||
|
||||
foreach ($TaskName in $TaskNames) {
|
||||
Write-Host ""
|
||||
Write-Host "===== $TaskName ====="
|
||||
$Task = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
||||
if ($null -eq $Task) {
|
||||
Write-Host "[ERROR] Task not found. Run setup_autostart.bat first." -ForegroundColor Red
|
||||
continue
|
||||
}
|
||||
|
||||
$Info = Get-ScheduledTaskInfo -TaskName $TaskName
|
||||
Write-Host "State: $($Task.State)"
|
||||
Write-Host "Run as: $($Task.Principal.UserId)"
|
||||
Write-Host "Last run: $($Info.LastRunTime)"
|
||||
Write-Host "Last result: $($Info.LastTaskResult)"
|
||||
Write-Host "Next run: $($Info.NextRunTime)"
|
||||
Write-Host "Execution limit: $($Task.Settings.ExecutionTimeLimit)"
|
||||
Write-Host "Action: $($Task.Actions.Execute) $($Task.Actions.Arguments)"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "===== HTTP health ====="
|
||||
try {
|
||||
$Response = Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:8010/service/meta" -TimeoutSec 8
|
||||
Write-Host "[OK] DocuTranslate responded with HTTP $($Response.StatusCode)." -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "[ERROR] DocuTranslate did not respond: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Result notes: 0 = last run succeeded; 267009 (0x41301) = task is running."
|
||||
Reference in New Issue
Block a user