Skip to content

Commit

Permalink
close #328 (#329)
Browse files Browse the repository at this point in the history
add a non-zero exit code in the event of an unclean shutdown
  • Loading branch information
Aaronontheweb authored Jun 19, 2023
1 parent 533c5c5 commit a751a98
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Akka.Hosting/AkkaHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public virtual async Task StartAsync(CancellationToken cancellationToken)
async Task TerminationHook()
{
await ActorSystem.WhenTerminated.ConfigureAwait(false);

/*
* Set a non-zero exit code in the event that we get a known, confirmed unclean shutdown
* from the ActorSystem / CoordinatedShutdown
*/
switch (CoordinatedShutdown.ShutdownReason)
{
case CoordinatedShutdown.ClusterDowningReason _:
case CoordinatedShutdown.ClusterLeavingReason _:
Environment.ExitCode = -1;
break;
}

HostApplicationLifetime?.StopApplication();
}

Expand Down

0 comments on commit a751a98

Please sign in to comment.