Browse Source

Dispose webapp on StopAsync (#70)

davidfowl/dependencies
Justin Kotalik 7 years ago
committed by GitHub
parent
commit
a2a4fd203a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Tye.Hosting/TyeHost.cs
  2. 4
      test/E2ETest/TyeRunTest.cs

11
src/Tye.Hosting/TyeHost.cs

@ -19,7 +19,7 @@ namespace Tye.Hosting
private Microsoft.Extensions.Logging.ILogger? _logger;
private IHostApplicationLifetime? _lifetime;
private AggregateApplicationProcessor? _processor;
private WebApplication? _app;
private readonly Application _application;
private readonly string[] _args;
@ -29,6 +29,8 @@ namespace Tye.Hosting
_args = args;
}
public WebApplication? DashboardWebApplication { get; set; }
public async Task RunAsync()
{
await StartAsync();
@ -43,7 +45,7 @@ namespace Tye.Hosting
public async Task<WebApplication> StartAsync()
{
var app = BuildWebApplication(_application, _args);
_app = app;
DashboardWebApplication = app;
ConfigureApplication(app);
@ -83,10 +85,11 @@ namespace Tye.Hosting
}
finally
{
if (_app != null)
if (DashboardWebApplication != null)
{
// Stop the host after everything else has been shutdown
await _app.StopAsync();
await DashboardWebApplication.StopAsync();
DashboardWebApplication.Dispose();
}
}
}

4
test/E2ETest/TyeRunTest.cs

@ -17,7 +17,7 @@ namespace E2ETest
{
var application = ConfigFactory.FromFile(new FileInfo(Path.Combine(GetSolutionRootDirectory("tye"), "samples", "single-project", "test-project", "test-project.csproj")));
var host = new TyeHost(application.ToHostingApplication(), new string[0]);
var webApplication = await host.StartAsync();
await host.StartAsync();
try
{
var handler = new HttpClientHandler
@ -30,7 +30,7 @@ namespace E2ETest
// Make sure dashboard and applications are up.
// Dashboard should be hosted in same process.
var dashboardResponse = await client.GetStringAsync(new Uri(webApplication.Addresses.First()));
var dashboardResponse = await client.GetStringAsync(new Uri(host.DashboardWebApplication!.Addresses.First()));
// Only one service for single application.
var service = application.Services.First();

Loading…
Cancel
Save