Hi,
I have written an automation script for processing some data for a custom application. I have been running into issues from time to time when the process will time out because it is not able to contact the DB for some reason or another. I have found that just rerunning the script tends to resolve the issue. So I wanted to implement a retry into the function. There is one line of code that makes a call to the data ingestion application. I then look for an exit code of 0. If I do not get an exit code of 0 I want to have the script wait 5 minutes then retry calling the application to ingest the data. Here is a sample of my code in the function.
D:\Programs\Application1\Appfolder\appfolder\appfilder\app.sh $TID
if($lastexitcode -ne 0)
{
Log-Write -LogPath $sLogFile -LineValue "DATA Processing Failed $LastExitCode [$([DateTime]::Now)]"
Log-Finish -LogPath $sLogFile -NoExit $True
Start-Sleep -s 10
# Zip ETL Logs
$env:DProgramFiles = "D:\Program Files"
set-alias sz "$env:DProgramFiles\7-Zip\7z.exe"
$Source2 = Get-ChildItem -Path $DEXLogs\* -Include *.log , *.txt | % { $_.FullName }
$Target2 = "$DEXLogs\$ItemProcessingDate.DATA.Log.zip"
sz a -mx=9 $Target2 $Source2
# Setup and send failure email
$emailBody = (Get-Content $sLogPath\$ItemProcessingDate.Processing.log | out-string)
$attachment = "$DATALogs\$ItemProcessingDate.DATA.Log.zip"
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubjectFailure -Body $emailBody -SmtpServer $emailSmtpServer -Attachments $attachment
Remove-Item $attachment
#Log-Email -LogPath $EmailLogPath -EmailFrom $EmailFrom -EmailTo $EmailTo -EmailSubject $EmailSubjectFailure
Exit 12
}
else
{
Log-Write -LogPath $sLogFile -LineValue "DATA Processing Completed [$([DateTime]::Now)]"
}