Browse Source

Tye run can fail to stop and hang (#84)

- Make TyeHost disposable and dispose it from the outside so that exceptions don't stop it from shutting down.
pull/86/head
David Fowler 7 years ago
committed by GitHub
parent
commit
4f83d1481d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Tye.Hosting/TyeHost.cs
  2. 6
      src/tye/Program.RunCommand.cs
  3. 2
      test/E2ETest/TyeRunTests.cs

18
src/Tye.Hosting/TyeHost.cs

@ -5,22 +5,22 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Tye.Hosting.Diagnostics;
using Tye.Hosting.Model;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Serilog; using Serilog;
using Serilog.Filters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog.Core; using Serilog.Core;
using Serilog.Events; using Serilog.Events;
using Serilog.Filters;
using Tye.Hosting.Diagnostics;
using Tye.Hosting.Model;
namespace Tye.Hosting namespace Tye.Hosting
{ {
public class TyeHost public class TyeHost : IDisposable
{ {
private Microsoft.Extensions.Logging.ILogger? _logger; private Microsoft.Extensions.Logging.ILogger? _logger;
private IHostApplicationLifetime? _lifetime; private IHostApplicationLifetime? _lifetime;
@ -98,7 +98,6 @@ namespace Tye.Hosting
{ {
// Stop the host after everything else has been shutdown // Stop the host after everything else has been shutdown
await DashboardWebApplication.StopAsync(); await DashboardWebApplication.StopAsync();
DashboardWebApplication.Dispose();
} }
} }
} }
@ -181,5 +180,10 @@ namespace Tye.Hosting
}); });
return processor; return processor;
} }
public void Dispose()
{
DashboardWebApplication?.Dispose();
}
} }
} }

6
src/tye/Program.RunCommand.cs

@ -55,7 +55,7 @@ namespace Tye
Required = false Required = false
}); });
command.Handler = CommandHandler.Create<IConsole, FileInfo>((console, path) => command.Handler = CommandHandler.Create<IConsole, FileInfo>(async (console, path) =>
{ {
// Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654 // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654
if (path is null) if (path is null)
@ -68,8 +68,8 @@ namespace Tye
InitializeThreadPoolSettings(serviceCount); InitializeThreadPoolSettings(serviceCount);
var host = new TyeHost(application.ToHostingApplication(), args); using var host = new TyeHost(application.ToHostingApplication(), args);
return host.RunAsync(); await host.RunAsync();
}); });
return command; return command;

2
test/E2ETest/TyeRunTests.cs

@ -37,7 +37,7 @@ namespace E2ETest
var projectFile = new FileInfo(Path.Combine(tempDirectory.DirectoryPath, "test-project.csproj")); var projectFile = new FileInfo(Path.Combine(tempDirectory.DirectoryPath, "test-project.csproj"));
var application = ConfigFactory.FromFile(projectFile); var application = ConfigFactory.FromFile(projectFile);
var host = new TyeHost(application.ToHostingApplication(), Array.Empty<string>()) using var host = new TyeHost(application.ToHostingApplication(), Array.Empty<string>())
{ {
Sink = sink, Sink = sink,
}; };

Loading…
Cancel
Save