diff --git a/src/MusicStore/Mocks/StartupSocialTesting.cs b/src/MusicStore/Mocks/StartupSocialTesting.cs index 4aacea4c88..bc2282d131 100644 --- a/src/MusicStore/Mocks/StartupSocialTesting.cs +++ b/src/MusicStore/Mocks/StartupSocialTesting.cs @@ -19,6 +19,8 @@ using MusicStore.Mocks.Common; using MusicStore.Mocks.Facebook; using MusicStore.Mocks.Twitter; using MusicStore.Mocks.Google; +using Microsoft.Framework.Runtime; +using System.Threading.Tasks; namespace MusicStore { @@ -88,6 +90,26 @@ namespace MusicStore services.AddInstance(new MemoryCache()); }); + //To gracefully shutdown the server - Not for production scenarios + app.Map("/shutdown", shutdown => + { + shutdown.Run(async context => + { + var appShutdown = context.ApplicationServices.GetService(); + appShutdown.RequestShutdown(); + + await Task.Delay(10 * 1000, appShutdown.ShutdownRequested); + if (appShutdown.ShutdownRequested.IsCancellationRequested) + { + await context.Response.WriteAsync("Shutting down gracefully"); + } + else + { + await context.Response.WriteAsync("Shutting down token not fired"); + } + }); + }); + //Configure SignalR app.UseSignalR();