Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FastKillOnCancelKeyPress not stopping the process. #3935

Merged
merged 6 commits into from
Feb 2, 2018
Merged
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
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