Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article explains how to gracefully shut down an Orleans silo before the app exits. This applies to apps running as console apps or container apps. Various termination signals can cause an app to shut down, such as Ctrl+C (or SIGTERM
). The following sections explain how to handle these signals.
Graceful silo shutdown
The following code shows how to gracefully shut down an Orleans silo console app. Consider the following example code:
using Microsoft.Extensions.Hosting;
using Orleans;
using Orleans.Hosting;
await Host.CreateDefaultBuilder(args)
.UseOrleans(siloBuilder =>
{
// Use the siloBuilder instance to configure the Orleans silo.
})
.RunConsoleAsync();
The preceding code relies on the Microsoft.Extensions.Hosting and Microsoft.Orleans.Server NuGet packages. The RunConsoleAsync extension method extends IHostBuilder to help manage the app's lifetime accordingly, listening for process termination signals and shutting down the silo gracefully.
Internally, the RunConsoleAsync
method calls UseConsoleLifetime, which ensures the app shuts down gracefully. For more information on host shutdown, see .NET Generic Host: Host shutdown.