Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Proto.Cluster/ClusterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ private ClusterConfig(string clusterName, IClusterProvider clusterProvider, IIde
/// </summary>
public bool LegacyRequestTimeoutBehavior { get; init; }

/// <summary>
/// Exit the application process when the cluster is terminated. Default is false.
/// </summary>
public bool ExitOnShutdown { get; set; } = false;

/// <summary>
/// Timeout for single retry of actor request. Default is 5s.
/// Overall timeout for the request is controlled by the cancellation token on
Expand Down Expand Up @@ -345,6 +350,15 @@ public ClusterConfig WithRemotePidCacheTimeToLive(TimeSpan timeout) =>
/// </summary>
public ClusterConfig WithLegacyRequestTimeoutBehavior(bool enabled = true) =>
this with { LegacyRequestTimeoutBehavior = enabled };


/// <summary>
/// Exit the application process when the cluster is shutdown.
/// </summary>
/// <param name="enabled"></param>
/// <returns></returns>
public ClusterConfig WithExitOnShutdown(bool enabled = true) =>
this with { ExitOnShutdown = enabled };

/// <summary>
/// Creates a new <see cref="ClusterConfig" />
Expand Down
6 changes: 5 additions & 1 deletion src/Proto.Cluster/ProtoActorLifecycleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public async Task StartAsync(CancellationToken _)
return;
}
_shutdownViaActorSystem = true;
_lifetime.StopApplication();

if (_actorSystem.Cluster().Config.ExitOnShutdown)
{
_lifetime.StopApplication();
}
});

if (_runAsClient)
Expand Down