Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

IApplicationShutdown.RequestShutdown is not honored on WebListener #71

Closed
@Praburaj

Description

@Praburaj

Send a request to the application. It is expected to serve the outstanding requests and die. This works as expected on Helios. On weblistener this event is not being honored.

On Kestrel the event seems to be honored, but the outstanding request is not served. The host process simply gets killed. I'm filing a separate bug for kestrel in kestrel repo.

public void Configure(IApplicationBuilder app)
 {
app.UseServices();
app.Run(async context =>
                {
                    Console.WriteLine("Received shutdown request...");
                    var appShutdownToken = context.ApplicationServices.GetService<IApplicationShutdown>();
                    appShutdownToken.RequestShutdown();

                    try
                    {
                        if (!appShutdownToken.ShutdownRequested.IsCancellationRequested)
                        {
                            await Task.Delay(10 * 1000, appShutdownToken.ShutdownRequested);
                        }
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                    }

                    if (appShutdownToken.ShutdownRequested.IsCancellationRequested)
                    {
                        await context.Response.WriteAsync("Shutting down gracefully");
                    }
                    else
                    {
                        await context.Response.WriteAsync("Shutting down token not fired");
                    }
                });          
  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions