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
Execute arbitrary code once a resource is up and running (some kind of "after start" event) #2155
Comments
I think we should add a hook that runs after the resources were told to start, but it doesn't mean they are healthy. Your code would still need to be resilient to that. |
It makes sense that my code should be resilient, as we cannot predict the behavior of the resources. However, I'm trying to understand the precise definition of "executing code after the resources were told to start." Does this mean it would trigger immediately after the .NET Aspire part has finished its job of pushing the desired state to the orchestrator? Or does the .NET Aspire part wait to receive at least some indication that the orchestrator attempted to start the resource, which could result in various states, such as: process not found, container not found, or resource has started (which doesn't mean it's healthy)? Thinking about it, it reminds me of CliWrap, which returns a CommandTask containing the process information if started (although the process could fail miserably) or throws an exception if the process wasn't found. If we cannot rely on such a signal, I could implement today an |
This. We tell the orchestrator to start, but we there's no concept of health in the system as yet |
So we're thinking somthing like interface IDistributedApplicationLifecycleHook
{
// Runs after resources have been orchestrated. There is no guarantee that the resources are healthy or ready for use at this point.
+ Task AfterStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken = default);
} Or |
Yea I think that's right. |
I prefer AfterResourcesCreatedAsync |
Currently, the
IDistributedApplicationLifecycleHook
hook only allows us to modify the app model before starting the resources. Is there a plan to add a hook that allows us to respond to an event indicating that a resource is up and running (or has failed to start, or any status change)? Does the orchestrator (DCP) support such a feature?The text was updated successfully, but these errors were encountered: