static Task StopEndpoints(IEnumerable<EndpointRunner> endpoints)
{
var stopTimeout = TimeSpan.FromMinutes(2);
return endpoints.Select(async endpoint =>
{
Console.WriteLine("Stopping endpoint: {0}", endpoint.Name());
var stopwatch = Stopwatch.StartNew();
try
{
await endpoint.Stop().ConfigureAwait(false);
stopwatch.Stop();
Console.WriteLine("Endpoint: {0} stopped ({1}s)", endpoint.Name(), stopwatch.Elapsed);
}
catch (Exception)
{
Console.WriteLine($"Endpoint {endpoint.Name()} failed to stop.");
throw;
}
}).Timebox(stopTimeout, $"Stopping endpoints took longer than {stopTimeout.TotalMinutes} minutes.");
}