private void OnShutdown(Model.ServiceHealthStatus serviceHealthStatus) { ServiceEventSource.Current.Message($"Shutdown process starting. Node: {Environment.GetEnvironmentVariable("HostedServiceName")}"); serviceHealthStatus.IsShuttingDown = true; System.Threading.Thread.Sleep(30000); ServiceEventSource.Current.Message($"Shutdown process complete. Node: {Environment.GetEnvironmentVariable("HostedServiceName")}"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, Model.ServiceHealthStatus serviceHealthStatus) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // register the applicationLifetime.ApplicationStopping.Register(() => OnShutdown(serviceHealthStatus)); app.UseMvc(); }