feat(dlp): graceful shutdown and COM cleanup for email collector
This commit is contained in:
@@ -610,7 +610,8 @@ if ($useOutlook) {
|
|||||||
# Main loop
|
# Main loop
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
while ($true) {
|
try {
|
||||||
|
while ($true) {
|
||||||
try {
|
try {
|
||||||
Flush-Wal
|
Flush-Wal
|
||||||
Write-CollectorHealth -Status 'running'
|
Write-CollectorHealth -Status 'running'
|
||||||
@@ -651,4 +652,23 @@ while ($true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Start-Sleep -Seconds $resolvedPollSeconds
|
Start-Sleep -Seconds $resolvedPollSeconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Write-CollectorHealth -Status 'stopped'
|
||||||
|
try {
|
||||||
|
if ($null -ne $script:SentFolder) {
|
||||||
|
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:SentFolder)
|
||||||
|
$script:SentFolder = $null
|
||||||
|
}
|
||||||
|
if ($null -ne $script:OutlookNamespace) {
|
||||||
|
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:OutlookNamespace)
|
||||||
|
$script:OutlookNamespace = $null
|
||||||
|
}
|
||||||
|
if ($null -ne $script:OutlookApp) {
|
||||||
|
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:OutlookApp)
|
||||||
|
$script:OutlookApp = $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user