Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for retrying failed Task processes #1487

Merged
merged 1 commit into from
Feb 9, 2025
Merged

Conversation

Badgerati
Copy link
Owner

Description of the Change

Adds support for being able to either automatically, or manually, retry failed Task processes.

  • Add-PodeTask has new -MaxRetries, -RetryDelay, and -AutoRetry parameters. These allow saying how many times to retry a process (default: 0), how many minutes between each retry (default: 0), and where Pode should auto-retry for you.
  • A new Restart-PodeTaskProcess function, for retrying failed Task processes. Can be used when -AutoRetry above is not supplied.

Related Issue

Resolves #1405

Examples

# auto-retry up to 3 times, at approx. 1 minute intervals
Add-PodeTask -Name 'Example' -MaxRetries 3 -RetryDelay 1 -AutoRetry -ScriptBlock {
    # do some work
    return $user
}
# allow the task to be retried up to 3 times
Add-PodeTask -Name 'Example' -MaxRetries 3 -ScriptBlock {
    # do some work
    return $user
}

# route to get failed processes, and retry them
Add-PodeRoute -Method Get -Path '/retry-tasks' -ScriptBlock {
    Get-PodeTaskProcess -State Failed | Foreach-Object {
        Restart-PodeTaskProcess -Process $_
    }
}

@Badgerati Badgerati added this to the 2.12.0 milestone Feb 9, 2025
@Badgerati Badgerati self-assigned this Feb 9, 2025
@Badgerati Badgerati merged commit e9e7334 into develop Feb 9, 2025
28 checks passed
@Badgerati Badgerati deleted the Issue-1405 branch February 9, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Retry ability for Failed Tasks
1 participant