Skip to content

Commit

Permalink
Fix FastKillOnCancelKeyPress not stopping the process. (#3935)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jms69 authored and sergeybykov committed Feb 2, 2018
1 parent d25d3bb commit 4d76acb
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Orleans.Runtime/Silo/Silo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private Task OnRuntimeInitializeStart(CancellationToken ct)
// Hook up to receive notification of process exit / Ctrl-C events
AppDomain.CurrentDomain.ProcessExit += HandleProcessExit;
if (this.siloOptions.FastKillOnCancelKeyPress)
Console.CancelKeyPress += HandleProcessExit;
Console.CancelKeyPress += HandleConsoleCancelKeyPress;
//TODO: setup thead pool directly to lifecycle
StartTaskWithPerfAnalysis("ConfigureThreadPoolAndServicePointSettings",
this.ConfigureThreadPoolAndServicePointSettings, Stopwatch.StartNew());
Expand Down Expand Up @@ -809,17 +809,14 @@ private void SafeExecute(Action action)
private void HandleProcessExit(object sender, EventArgs e)
{
// NOTE: We need to minimize the amount of processing occurring on this code path -- we only have under approx 2-3 seconds before process exit will occur
logger.Warn(ErrorCode.Runtime_Error_100220, "Process is exiting");

lock (lockable)
{
if (!this.SystemStatus.Equals(SystemStatus.Running)) return;

this.SystemStatus = SystemStatus.Stopping;
}

logger.Info(ErrorCode.SiloStopping, "Silo.HandleProcessExit() - starting to FastKill()");
Stop();
this.logger.Warn(ErrorCode.Runtime_Error_100220, "Process is exiting");
this.Stop();
}

private void HandleConsoleCancelKeyPress(object sender, EventArgs e)
{
// Gracefully terminate the silo.
this.Shutdown();
}

internal void RegisterSystemTarget(SystemTarget target)
Expand Down

0 comments on commit 4d76acb

Please sign in to comment.