JasperFx/oakton

(Web) Application does not exit gracefully when receiving `SIGTERM`

agross opened this issue · 0 comments

This is the Program.cs of a new web application minus the unnecessary defaults.

using Oakton;

var builder = WebApplication.CreateBuilder(args);

builder.Host.ApplyOaktonExtensions();

var app = builder.Build();

return await app.RunOaktonCommands(args);

When the application is started and a SIGTERM is sent (kill -TERM <pid>), the shutdown hangs indefinitely:

$ ./WebOakton


info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /Users/agross/Downloads/WebOakton/bin/Debug/net7.0
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...