-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Some thoughts on graceful shutdown, either for app pool recycle or server reboot. Event can fire to notify clients.
public void ConfigureServices(IServiceCollection services)
{
services.AddSignalR();
services.AddSingleton<IApplicationLifetime>(provider =>
{
var lifetime = provider.GetService<IHostApplicationLifetime>();
return lifetime;
});
}
then
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApplicationLifetime lifetime)
{
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<DashboardHub>("/dashboardHub", options =>
{
options.AddHubOptions<DashboardHub>(o =>
{
o.AddClient lifetime);
});
});
});
}
then
public class DashboardHub: Hub
{
private readonly IApplicationLifetime _lifetime;
private static CAD _cad;
public DashboardHub(IApplicationLifetime lifetime, CAD cad)
{
_lifetime = lifetime;
_lifetime.ApplicationStopping.Register(OnStopping);
_cad = cad;
}
private void OnStopping()
{
// Code to handle the shutdown goes here
}
}
There may be better ways to handle this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request