JasperFx/oakton

Console application doesn't exit when using RunOaktonCommands for HostBuilder

nzscout opened this issue · 1 comments

When using code below the application remains running after Startup.StartAsync completed. When I replace .RunOaktonCommands(args); with .RunConsoleAsync(); it shuts down fine

       static Task<int> Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
                .Build();

            return CreateHostBuilder(args).ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                }
                )
                .UseSerilog()
                .ConfigureServices((_, services) =>
                {
                    services.AddDescription<OaktonConfigDescription>();
                    services.AddHostedService<Startup>();
                }
                ).RunOaktonCommands(args); 
        }

Sorry, just now seeing this. Oakton shouldn't be exiting if you just run "run". By design, it should hold the host until you call CTRL-C in this case.