public void Abort() { _heartbeat.ShutdownAsync(); foreach (var process in Members) { if (process is IServerProcess serverProcess) { ServiceRegistrar?.EnsureRemoved(serverProcess); } process.Kill(); } }
public static async Task <string> ShutDownAsync( [NotNull] IManagedProcess process, [CanBeNull] ServiceRegistrar serviceRegistrar, TimeSpan maxShutDownTime) { string message = null; if (process.IsKnownRunning) { process.MonitoringSuspended = true; try { if (process is IServerProcess serverProcess) { serviceRegistrar?.EnsureRemoved(serverProcess); } bool isShutDown = false; if (maxShutDownTime > TimeSpan.Zero) { isShutDown = await process.TryShutdownAsync(maxShutDownTime); } if (!isShutDown) { message = $"Process has not shut down within {maxShutDownTime.TotalSeconds}s. We had to kill it."; process.Kill(); } } finally { process.MonitoringSuspended = false; } } return(message); }
private async Task <bool> CareForUnavailable([NotNull] IManagedProcess process) { _logger.LogInformation("(Re-)starting process due to request time-out: {process}", process); if (process is IServerProcess serverProcess) { ServiceRegistrar?.EnsureRemoved(serverProcess); } if (process.StartupFailureCount > MemberMaxStartupRetries) { _logger.LogWarning("Startup retries have been exceeded. Not starting {process}", process); } else { return(await TryStart(process)); } return(true); }
public async Task <bool> ShutdownAsync(TimeSpan timeout) { await _heartbeat.ShutdownAsync(); var shutDownResults = await Task.WhenAll(Members.Select(m => { if (m is IServerProcess serverProcess) { ServiceRegistrar?.EnsureRemoved(serverProcess); } if (m.ClusterShutdownAction == ShutdownAction.Kill) { m.Kill(); } //return m.TryShutdownAsync(timeout); return(Task.FromResult(true)); })); return(shutDownResults.All(r => r)); }