microsoft / microsoft/aspire

Support restart on fail for executables and containers

Open
#1,708 16 comments 8 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

When container A starts, the service in container A needs some startup time. At this time, service B has already started and is highly dependent on the service in container A. Therefore, service B ends due to an exception, such as the subscription dependency of Dapr sidecar. on the RabbitMQ service queue.

```csharp
builder.AddRabbitMQContainer("rabbitmq")
.WithVolumeMount("./configs/rabbitmq/enabled_plugins.conf", "/etc/rabbitmq/enabled_plugins")
.WithVolumeMount("./configs/rabbitmq/rabbitmq.conf", "/etc/rabbitmq/rabbitmq.conf")
.WithEndpoint(1883, 1883)
.WithEndpoint(15672, 15672)
.WithEndpoint(5672, 5672)
.WithEnvironment("TZ", "Asia/Shanghai");

var apiService = builder.AddProject("apiservice");
var apiServiceDapr = apiService.WithDaprSidecar(sidecarBuilder =>
{
sidecarBuilder.WithOptions(new DaprSidecarOptions
{
AppId = "apiservice",
ResourcesPaths = ["./components"],
LogLevel = "debug"
})
.WithEnvironment("AMQP_CONNECTION_STRING", "amqp://test:hellotest@localhost:5672")
.WithEnvironment("MQTT_CONNECTION_STRING", "tcp://test:hellotest@localhost:1883");
});
```
In the above code, the container has been started, but RabbitMQ in the container has not yet been started. At this time, the Dapr sidecar has been started and requires the RabbitMQ service. However, because the service cannot be found, the Dapr sidecar stops working and there is nothing to set. Try the restart strategy, and then although RabbitMQ has started successfully, Dapr becomes dead.

Wish there was an option to automatically try to restart after failure, so that would solve the problem.

The container can be restarted after failure through startup parameter settings, but I don't want to containerize the Dapr sidecar, so there is no option to restart.

```csharp
sidecarBuilder.WithRestartAlways()
.WithRestartAlways(10) // 10 seconds
```

Hopefully something like this setup.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.