man-group / dapr-sidekick-dotnet

Dapr Sidekick for .NET - a lightweight lifetime management component for Dapr
Apache License 2.0
175 stars 21 forks source link

Delay Sidecar Startup until Host Application Started #36

Closed badgeratu closed 2 years ago

badgeratu commented 2 years ago

Expected Behavior

Under ASP.NET Core Sidekick should be launched only when the Host Application is fully started, i.e. when the Kestrel port is opened and the full middleware pipeline is initialized.

Actual Behavior

Sidekick currently starts Dapr Sidecar asynchronously using an IHostedService, which means it is started before the ASP.NET GenericWebHostService hosted service is started to initialize the middleware pipeline and open the host port. This means any environment variables or initialization properties set during the middleware construction may not be passed to the Dapr Sidecar, resulting in potentially missing metadata entries in Consul or anywhere else that relies on environment variables in the yaml files.

We should instead wait until IHostApplicationLifetime.ApplicationStarted signals the application has started before starting the Sidecar process.

Steps to Reproduce the Problem

N/A

Release Note

RELEASE NOTE: FIX Delay Sidecar Startup until Host Application Started