From 2695ff04a06a3c41ebbdd9d9316b712d3cf14928 Mon Sep 17 00:00:00 2001 From: pvds <36538317+pawelvds@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:05:38 +0200 Subject: [PATCH 1/5] Added functionality to capture logs from Plebian and log them in Monarch --- .../ProcessHost/ProcessHostMonarch.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index 881e57e0..3bd5913d 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -51,6 +51,22 @@ public ProcessHostMonarch(ILogger logger, LauncherConfigurat _process.EnableRaisingEvents = true; _stopped = new TaskCompletionSource(); _started = new TaskCompletionSource(); + + _process.OutputDataReceived += (sender, e) => + { + if (e.Data != null) + { + _logger.LogInformation($"Plebian Output: {e.Data}"); + } + }; + + _process.ErrorDataReceived += (sender, e) => + { + if (e.Data != null) + { + _logger.LogError($"Plebian Error: {e.Data}"); + } + }; } public Task Start(CancellationToken cancellationToken) @@ -87,11 +103,14 @@ public Task Start(CancellationToken cancellationToken) _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } - catch { } + catch + { + _logger.LogError("Error while initiating the output and error read lines."); + } } catch (Exception ex) { - _logger.LogError(ex, "Could not start ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + _logger.LogError(ex, "Could not restart ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); _started.TrySetResult(); _stopped.TrySetCanceled(cancellationToken); } From 521eafabdf4c4fb14a8683b731e842cd9ded2b61 Mon Sep 17 00:00:00 2001 From: PawelKarczewski Date: Mon, 23 Oct 2023 12:06:27 +0200 Subject: [PATCH 2/5] ImprovedProcessHostMonarch logging and error handling --- .../ProcessHost/ProcessHostMonarch.cs | 73 ++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index 3bd5913d..3605bf7c 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -4,6 +4,7 @@ using fiskaltrust.Launcher.Constants; using fiskaltrust.Launcher.Helpers; using fiskaltrust.storage.serialization.V0; +using Microsoft.Extensions.Logging; namespace fiskaltrust.Launcher.ProcessHost { @@ -23,50 +24,55 @@ public class ProcessHostMonarch : IProcessHostMonarch private readonly TaskCompletionSource _stopped; private readonly PackageConfiguration _packageConfiguration; private readonly ILogger _logger; + private readonly List _plebianLogBuffer = new List(); public ProcessHostMonarch(ILogger logger, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PackageType packageType, LauncherExecutablePath launcherExecutablePath) { _packageConfiguration = packageConfiguration; _logger = logger; - _process = new Process(); - _process.StartInfo.UseShellExecute = false; - _process.StartInfo.FileName = launcherExecutablePath.Path; - _process.StartInfo.CreateNoWindow = false; - - _process.StartInfo.Arguments = string.Join(" ", new string[] { - "host", - "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = packageType, PackageId = packageConfiguration.Id }.Serialize()))}\"", - "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(launcherConfiguration.Serialize()))}\"", - }); - + _process = new Process + { + StartInfo = new ProcessStartInfo + { + UseShellExecute = false, + FileName = launcherExecutablePath.Path, + CreateNoWindow = false, + Arguments = string.Join(" ", new string[] { + "host", + "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = packageType, PackageId = packageConfiguration.Id }.Serialize()))}\"", + "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(launcherConfiguration.Serialize()))}\"", + }), + RedirectStandardInput = true, + RedirectStandardError = true, + RedirectStandardOutput = true + }, + EnableRaisingEvents = true + }; + // if (Debugger.IsAttached) // { // _process.StartInfo.Arguments += " --debugging"; // } - _process.StartInfo.RedirectStandardInput = true; - _process.StartInfo.RedirectStandardError = true; - _process.StartInfo.RedirectStandardOutput = true; - _process.EnableRaisingEvents = true; - _stopped = new TaskCompletionSource(); - _started = new TaskCompletionSource(); - - _process.OutputDataReceived += (sender, e) => + _process.OutputDataReceived += (sender, e) => { - if (e.Data != null) + if (e.Data != null) { - _logger.LogInformation($"Plebian Output: {e.Data}"); + _plebianLogBuffer.Add($"Plebian Output: {e.Data}"); } }; - _process.ErrorDataReceived += (sender, e) => + _process.ErrorDataReceived += (sender, e) => { - if (e.Data != null) + if (e.Data != null) { - _logger.LogError($"Plebian Error: {e.Data}"); + _plebianLogBuffer.Add($"Plebian Error: {e.Data}"); } }; + + _stopped = new TaskCompletionSource(); + _started = new TaskCompletionSource(); } public Task Start(CancellationToken cancellationToken) @@ -88,6 +94,23 @@ public Task Start(CancellationToken cancellationToken) { _logger.LogInformation("Host {package} {id} has shutdown.", _packageConfiguration.Package, _packageConfiguration.Id); + if (_process.ExitCode != 0) + { + foreach (var log in _plebianLogBuffer) + { + if (log.Contains("Error")) + { + _logger.LogError(log); + } + else + { + _logger.LogInformation(log); + } + } + } + + _plebianLogBuffer.Clear(); + await Task.Delay(1000); if (!cancellationToken.IsCancellationRequested) { @@ -103,7 +126,7 @@ public Task Start(CancellationToken cancellationToken) _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } - catch + catch { _logger.LogError("Error while initiating the output and error read lines."); } From abdc18f5a96195fff525e64598fac31b40f860d5 Mon Sep 17 00:00:00 2001 From: PawelKarczewski Date: Mon, 23 Oct 2023 22:04:56 +0200 Subject: [PATCH 3/5] Moved the Plebian output code check condition and log buffer clean-up to improve error handling and logging --- .../ProcessHost/ProcessHostMonarch.cs | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index 3605bf7c..a051f08c 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -59,7 +59,7 @@ public ProcessHostMonarch(ILogger logger, LauncherConfigurat { if (e.Data != null) { - _plebianLogBuffer.Add($"Plebian Output: {e.Data}"); + _plebianLogBuffer.Add(e.Data); } }; @@ -94,29 +94,19 @@ public Task Start(CancellationToken cancellationToken) { _logger.LogInformation("Host {package} {id} has shutdown.", _packageConfiguration.Package, _packageConfiguration.Id); - if (_process.ExitCode != 0) + await Task.Delay(1000); + if (!cancellationToken.IsCancellationRequested) { - foreach (var log in _plebianLogBuffer) + try { - if (log.Contains("Error")) + if (_process.ExitCode != 0) { - _logger.LogError(log); + var errorMessage = string.Join("\n", _plebianLogBuffer); + _logger.LogError("Error when starting {package} {id}.\n{error}", _packageConfiguration.Package, _packageConfiguration.Id, errorMessage); + _started.TrySetResult(); + _stopped.TrySetCanceled(cancellationToken); } else - { - _logger.LogInformation(log); - } - } - } - - _plebianLogBuffer.Clear(); - - await Task.Delay(1000); - if (!cancellationToken.IsCancellationRequested) - { - if (_process.ExitCode != 0) - { - try { _logger.LogInformation("Restarting {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); if (!_process.Start()) { throw new Exception($"Process.Start() was false for {_packageConfiguration.Package} {_packageConfiguration.Id}"); } @@ -126,22 +116,17 @@ public Task Start(CancellationToken cancellationToken) _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } - catch + catch { _logger.LogError("Error while initiating the output and error read lines."); } } - catch (Exception ex) - { - _logger.LogError(ex, "Could not restart ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); - _started.TrySetResult(); - _stopped.TrySetCanceled(cancellationToken); - } } - else + catch (Exception ex) { - _started.TrySetCanceled(); - _stopped.SetResult(); + _logger.LogError(ex, "Could not restart ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + _started.TrySetResult(); + _stopped.TrySetCanceled(cancellationToken); } } else @@ -150,7 +135,7 @@ public Task Start(CancellationToken cancellationToken) _stopped.SetResult(); } }; - + try { if (!_process.Start()) { throw new Exception("Process.Start() was false"); } From bc51028b601d13f786ee6037e128d1029c928609 Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Tue, 24 Oct 2023 16:26:18 +0200 Subject: [PATCH 4/5] improve plebian process handling --- .../Commands/DoctorCommand.cs | 6 +- .../Commands/HostCommand.cs | 8 +- .../ProcessHost/ProcessHostMonarcStartup.cs | 10 +- .../ProcessHost/ProcessHostMonarch.cs | 240 +++++++++++------- .../ProcessHost/ProcessHostPlebian.cs | 17 +- .../Services/ProcessHostService.cs | 2 +- .../Plebian/PlebianTests.cs | 2 +- 7 files changed, 181 insertions(+), 104 deletions(-) diff --git a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs index e88ebaa9..159830dc 100644 --- a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs @@ -353,15 +353,17 @@ public Task Start(CancellationToken cancellationToken) return Task.CompletedTask; } - public void Started() + public void SetPlebeanStarted() { IsStarted.SetResult(); } - public Task Stopped() + public Task GetStopped() { return Task.CompletedTask; } + + public void SetStartupCompleted() { } } public class DoctorMiddlewareBootstrapper : IMiddlewareBootstrapper diff --git a/src/fiskaltrust.Launcher/Commands/HostCommand.cs b/src/fiskaltrust.Launcher/Commands/HostCommand.cs index 90168609..965c4d8a 100644 --- a/src/fiskaltrust.Launcher/Commands/HostCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/HostCommand.cs @@ -96,7 +96,11 @@ public async Task InvokeAsync(InvocationContext context) .UseSerilog() .ConfigureServices(services => { - services.Configure(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(30)); + services.Configure(opts => + { + opts.ShutdownTimeout = TimeSpan.FromSeconds(30); + opts.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.StopHost; + }); services.AddSingleton(_ => launcherConfiguration); services.AddSingleton(_ => packageConfiguration); services.AddSingleton(_ => plebianConfiguration); @@ -162,7 +166,7 @@ public async Task InvokeAsync(InvocationContext context) catch (Exception e) { Log.Error(e, "An unhandled exception occured."); - return 1; + throw; } finally { diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarcStartup.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarcStartup.cs index 8d73991f..4e73d389 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarcStartup.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarcStartup.cs @@ -79,17 +79,23 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) await new TaskCompletionSource().Task; } + foreach (var host in _hosts) + { + host.Value.SetStartupCompleted(); + } + try { - await Task.WhenAll(_hosts.Select(h => h.Value.Stopped())); + await Task.WhenAll(_hosts.Select(h => h.Value.GetStopped())); } catch { - foreach (var failed in _hosts.Where(h => !h.Value.Stopped().IsCompletedSuccessfully).Select(h => (h.Key, h.Value.Stopped().Exception))) + foreach (var failed in _hosts.Where(h => !h.Value.GetStopped().IsCompletedSuccessfully).Select(h => (h.Key, h.Value.GetStopped().Exception))) { _logger.LogWarning(failed.Exception, "ProcessHost {Id} had crashed.", failed.Key); } } + _lifetime.ApplicationLifetime.StopApplication(); } private async Task StartProcessHostMonarch(PackageConfiguration configuration, PackageType packageType, CancellationToken cancellationToken) diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index a051f08c..87e0421d 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -2,6 +2,7 @@ using fiskaltrust.Launcher.Common.Configuration; using fiskaltrust.Launcher.Configuration; using fiskaltrust.Launcher.Constants; +using fiskaltrust.Launcher.Extensions; using fiskaltrust.Launcher.Helpers; using fiskaltrust.storage.serialization.V0; using Microsoft.Extensions.Logging; @@ -11,37 +12,59 @@ namespace fiskaltrust.Launcher.ProcessHost public interface IProcessHostMonarch { public Task Start(CancellationToken cancellationToken); - - public void Started(); - - public Task Stopped(); + public void SetPlebeanStarted(); + public void SetStartupCompleted(); + public Task GetStopped(); } public class ProcessHostMonarch : IProcessHostMonarch { - private readonly Process _process; - private readonly TaskCompletionSource _started; - private readonly TaskCompletionSource _stopped; + private Process? _process; + private TaskCompletionSource _started; + private bool _monarchStartupCompleted; + private TaskCompletionSource _stopped; + private TimeSpan _restartDelay = TimeSpan.FromSeconds(1); + private readonly PackageConfiguration _packageConfiguration; private readonly ILogger _logger; private readonly List _plebianLogBuffer = new List(); + private LauncherConfiguration _launcherConfiguration; + private PackageType _packageType; + private LauncherExecutablePath _launcherExecutablePath; + public ProcessHostMonarch(ILogger logger, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PackageType packageType, LauncherExecutablePath launcherExecutablePath) { _packageConfiguration = packageConfiguration; + _launcherConfiguration = launcherConfiguration; + _packageType = packageType; + _launcherExecutablePath = launcherExecutablePath; _logger = logger; + _monarchStartupCompleted = false; + + _stopped = new TaskCompletionSource(); + _started = new TaskCompletionSource(); + + // if (Debugger.IsAttached) + // { + // _process.StartInfo.Arguments += " --debugging"; + // } + } + + private void Setup() + { _process = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, - FileName = launcherExecutablePath.Path, + FileName = _launcherExecutablePath.Path, CreateNoWindow = false, Arguments = string.Join(" ", new string[] { "host", - "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = packageType, PackageId = packageConfiguration.Id }.Serialize()))}\"", - "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(launcherConfiguration.Serialize()))}\"", + "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"", + "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(_launcherConfiguration.Serialize()))}\"", }), RedirectStandardInput = true, RedirectStandardError = true, @@ -49,120 +72,155 @@ public ProcessHostMonarch(ILogger logger, LauncherConfigurat }, EnableRaisingEvents = true }; - - // if (Debugger.IsAttached) - // { - // _process.StartInfo.Arguments += " --debugging"; - // } - _process.OutputDataReceived += (sender, e) => - { - if (e.Data != null) - { - _plebianLogBuffer.Add(e.Data); - } - }; + _process.OutputDataReceived += ReceiveStdOut; + _process.ErrorDataReceived += ReceiveStdOut; + } - _process.ErrorDataReceived += (sender, e) => + private void ReceiveStdOut(object sender, DataReceivedEventArgs e) + { + if (e.Data != null) { - if (e.Data != null) - { - _plebianLogBuffer.Add($"Plebian Error: {e.Data}"); - } - }; - - _stopped = new TaskCompletionSource(); - _started = new TaskCompletionSource(); + _plebianLogBuffer.Add(e.Data); + } } - public Task Start(CancellationToken cancellationToken) + private void HandleCancellation() { - cancellationToken.Register(() => + _logger.LogDebug("Handeling cancellation {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + + try { - try + if (_process is not null && !_process.HasExited) { - if (!_process.HasExited) - { - _logger.LogInformation("Killing {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); - _process.Kill(); - } + _logger.LogInformation("Killing {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + _process.Kill(); } - catch { } - }); + } + catch { } + } - _process.Exited += async (_, __) => + private async Task HandleExit(CancellationToken cancellationToken) + { + + if (cancellationToken.IsCancellationRequested /* || (_process is not null && _process.ExitCode == 0) */) // Until https://github.com/dotnet/runtime/issues/67146 is addressed we cannot check the exit code. { _logger.LogInformation("Host {package} {id} has shutdown.", _packageConfiguration.Package, _packageConfiguration.Id); + // Cancellation was requested, and the process has exited. + // Or the process has exited gracefully. + _started.TrySetResult(); + _stopped.SetResult(); + return; + } + + // if (_process is not null && _process.ExitCode != 0) + { + _logger.LogWarning("Host {package} {id} has crashed.", _packageConfiguration.Package, _packageConfiguration.Id); + } + + // Cancellation was not requested, and the process has exited erroniously. + if (!_started.Task.IsCompleted) + { + // If the process hat not signaled startup, we print the log buffer. + _logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebianLogBuffer)); + _plebianLogBuffer.Clear(); + } + + // Plebian crash happened during the startup phase so we don't went to keep restarting. + if (!_monarchStartupCompleted) + { + _started.TrySetCanceled(); + _stopped.TrySetCanceled(); + return; + } + + _logger.LogInformation("Backing off restart {delay} for {package} {id}.", _restartDelay, _packageConfiguration.Package, _packageConfiguration.Id); + + _restartDelay *= 2; + try + { + await Task.Delay(_restartDelay, cancellationToken); + } + catch (TaskCanceledException) + { + return; + } + + _logger.LogInformation("Restarting {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + + try + { + StartProcess(cancellationToken); + } + catch (Exception ex) + { + _logger.LogError(ex, "Could not start ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); + _started.TrySetResult(); + _stopped.TrySetCanceled(); + } + + } + + private void StartProcess(CancellationToken cancellationToken) + { + if (cancellationToken.IsCancellationRequested) { return; } + + Setup(); + + _process!.Exited += (_, _) => { var _ = Task.Run(async () => await HandleExit(cancellationToken)); }; + + if (!_process!.Start()) { throw new Exception($"Process.Start() was false for {_packageConfiguration.Package} {_packageConfiguration.Id}"); } - await Task.Delay(1000); - if (!cancellationToken.IsCancellationRequested) - { - try - { - if (_process.ExitCode != 0) - { - var errorMessage = string.Join("\n", _plebianLogBuffer); - _logger.LogError("Error when starting {package} {id}.\n{error}", _packageConfiguration.Package, _packageConfiguration.Id, errorMessage); - _started.TrySetResult(); - _stopped.TrySetCanceled(cancellationToken); - } - else - { - _logger.LogInformation("Restarting {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); - if (!_process.Start()) { throw new Exception($"Process.Start() was false for {_packageConfiguration.Package} {_packageConfiguration.Id}"); } - - try - { - _process.BeginOutputReadLine(); - _process.BeginErrorReadLine(); - } - catch - { - _logger.LogError("Error while initiating the output and error read lines."); - } - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Could not restart ProcessHost process for {package} {id}.", _packageConfiguration.Package, _packageConfiguration.Id); - _started.TrySetResult(); - _stopped.TrySetCanceled(cancellationToken); - } - } - else - { - _started.TrySetResult(); - _stopped.SetResult(); - } - }; - try { - if (!_process.Start()) { throw new Exception("Process.Start() was false"); } _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } + catch { } + } + + + public Task Start(CancellationToken cancellationToken) + { + cancellationToken.Register(HandleCancellation); + + try + { + StartProcess(cancellationToken); + } catch (Exception e) { _logger.LogError(e, "Could not start ProcessHost process."); - _stopped.SetCanceled(cancellationToken); + _stopped!.TrySetCanceled(cancellationToken); return Task.CompletedTask; } - _logger.LogDebug("ProcessId {id}", _process.Id); + + _logger.LogDebug("ProcessId {id}", _process?.Id); if (Debugger.IsAttached) { - Debug.WriteLine($"ProcessId {_process.Id}"); + Debug.WriteLine($"ProcessId {_process?.Id}"); } return _started.Task; } - public void Started() + public void SetPlebeanStarted() + { + _started.TrySetResult(); + if (_process is not null) + { + _process.OutputDataReceived -= ReceiveStdOut; + _process.ErrorDataReceived -= ReceiveStdOut; + } + _plebianLogBuffer.Clear(); + } + + public void SetStartupCompleted() { - _started.SetResult(); + _monarchStartupCompleted = true; } - public Task Stopped() + public Task GetStopped() { return _stopped.Task; } diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs index bcfe5e1b..256cdc76 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs @@ -53,11 +53,10 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) helper.StartEnd(); } } - catch (Exception e) + catch { - _logger.LogError(e, "Error Starting Hosting"); - _lifetime.StopApplication(); - return; + _logger.LogError("Error Starting Hosting"); + throw; } _processHostService?.Started(_packageConfiguration.Id.ToString()); @@ -72,7 +71,15 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) if (_plebianConfiguration.PackageType == PackageType.Helper) { - var helper = _services.GetRequiredService(); + IHelper helper; + try + { + helper = _services.GetRequiredService(); + } + catch (ObjectDisposedException) + { + return; + } helper.StopBegin(); helper.StopEnd(); }; diff --git a/src/fiskaltrust.Launcher/Services/ProcessHostService.cs b/src/fiskaltrust.Launcher/Services/ProcessHostService.cs index 25218b64..11b29771 100644 --- a/src/fiskaltrust.Launcher/Services/ProcessHostService.cs +++ b/src/fiskaltrust.Launcher/Services/ProcessHostService.cs @@ -24,7 +24,7 @@ public ProcessHostService(Dictionary hosts, Serilog.I [OperationContract] public void Started(string id) { - _hosts[Guid.Parse(id)].Started(); + _hosts[Guid.Parse(id)].SetPlebeanStarted(); } [OperationContract] diff --git a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs b/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs index 3897e2c4..500ea873 100644 --- a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs +++ b/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs @@ -240,7 +240,7 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig var monarch = Mock.Of(); var logger = Mock.Of(MockBehavior.Strict); Mock.Get(logger).Setup(x => x.Information(It.IsAny())).Verifiable(); - Mock.Get(monarch).Setup(x => x.Started()).Callback(() => started.SetResult()); + Mock.Get(monarch).Setup(x => x.SetPlebeanStarted()).Callback(() => started.SetResult()); var processHostService = new ProcessHostService(new Dictionary { { packageConfiguration.Id, monarch } }, Mock.Of()); var services = new ServiceCollection(); From cfd28da562815fafcebbb06611e760ef344b9c6e Mon Sep 17 00:00:00 2001 From: Paul Volavsek Date: Tue, 24 Oct 2023 16:29:03 +0200 Subject: [PATCH 5/5] rename plebeian --- .../Commands/DoctorCommand.cs | 22 ++++++++--------- .../Commands/HostCommand.cs | 14 +++++------ .../Configuration/PlebianConfiguration.cs | 6 ++--- .../Helpers/SerializerContext.cs | 2 +- .../ProcessHost/ProcessHostMonarch.cs | 14 +++++------ ...sHostPlebian.cs => ProcessHostPlebeian.cs} | 18 +++++++------- .../Services/EncodingProvider.cs | 2 +- .../PlebeianTests.cs} | 24 +++++++++---------- 8 files changed, 51 insertions(+), 51 deletions(-) rename src/fiskaltrust.Launcher/ProcessHost/{ProcessHostPlebian.cs => ProcessHostPlebeian.cs} (89%) rename test/fiskaltrust.Launcher.IntegrationTest/{Plebian/PlebianTests.cs => Plebeian/PlebeianTests.cs} (92%) diff --git a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs index 159830dc..36266d91 100644 --- a/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/DoctorCommand.cs @@ -158,7 +158,7 @@ public async Task InvokeAsync(InvocationContext context) await CheckAwait("Start monarch WebApplication", async () => await WithTimeout(async () => await monarchApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5)), throws: true); - var plebianConfiguration = new PlebianConfiguration + var plebeianConfiguration = new PlebeianConfiguration { PackageId = doctorId, PackageType = Constants.PackageType.Queue @@ -167,24 +167,24 @@ public async Task InvokeAsync(InvocationContext context) var packageConfiguration = new PackageConfiguration { Configuration = new(), - Id = plebianConfiguration.PackageId, + Id = plebeianConfiguration.PackageId, Package = "none", Url = Array.Empty(), Version = "1.0.0" }; - IProcessHostService? processHostService = Check("Start plebian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService()); + IProcessHostService? processHostService = Check("Start plebeian processhostservice client", () => GrpcChannel.ForAddress($"http://localhost:{launcherConfiguration.LauncherPort}").CreateGrpcService()); - var plebianBuilder = Host.CreateDefaultBuilder() + var plebeianBuilder = Host.CreateDefaultBuilder() .UseSerilog(new LoggerConfiguration().CreateLogger()) .ConfigureServices(services => { - Check("Setup plebian services", () => + Check("Setup plebeian services", () => { services.Configure(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(30)); services.AddSingleton(_ => launcherConfiguration); services.AddSingleton(_ => packageConfiguration); - services.AddSingleton(_ => plebianConfiguration); + services.AddSingleton(_ => plebeianConfiguration); var pluginLoader = new PluginLoader(); services.AddSingleton(_ => pluginLoader); @@ -195,7 +195,7 @@ public async Task InvokeAsync(InvocationContext context) } services.AddSingleton(); - services.AddHostedService(); + services.AddHostedService(); services.AddSingleton, DESSCDClientFactory>(); services.AddSingleton, POSClientFactory>(); @@ -212,9 +212,9 @@ public async Task InvokeAsync(InvocationContext context) }, throws: true); }); - var plebianApp = Check("Build plebian Host", plebianBuilder.Build, throws: true)!; + var plebeianApp = Check("Build plebeian Host", plebeianBuilder.Build, throws: true)!; - await CheckAwait("Start plebian Host", async () => await WithTimeout(async () => await plebianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5))); + await CheckAwait("Start plebeian Host", async () => await WithTimeout(async () => await plebeianApp.StartAsync(_lifetime.ApplicationLifetime.ApplicationStopping), TimeSpan.FromSeconds(5))); await doctorProcessHostMonarch.IsStarted.Task; @@ -225,8 +225,8 @@ await CheckAwait("Shutdown launcher gracefully", async () => await WithTimeout(a await monarchApp.StopAsync(); await monarchApp.WaitForShutdownAsync(); - await plebianApp.StopAsync(); - await plebianApp.WaitForShutdownAsync(); + await plebeianApp.StopAsync(); + await plebeianApp.WaitForShutdownAsync(); }, TimeSpan.FromSeconds(5)) ); } diff --git a/src/fiskaltrust.Launcher/Commands/HostCommand.cs b/src/fiskaltrust.Launcher/Commands/HostCommand.cs index 965c4d8a..bb6bec54 100644 --- a/src/fiskaltrust.Launcher/Commands/HostCommand.cs +++ b/src/fiskaltrust.Launcher/Commands/HostCommand.cs @@ -28,7 +28,7 @@ public class HostCommand : Command { public HostCommand() : base("host") { - AddOption(new Option("--plebian-configuration")); + AddOption(new Option("--plebeian-configuration")); AddOption(new Option("--debugging")); AddOption(new Option("--launcher-configuration")); AddOption(new Option("--no-process-host-service", getDefaultValue: () => false)); @@ -38,7 +38,7 @@ public HostCommand() : base("host") public class HostCommandHandler : ICommandHandler { public string LauncherConfiguration { get; set; } = null!; - public string PlebianConfiguration { get; set; } = null!; + public string PlebeianConfiguration { get; set; } = null!; public bool NoProcessHostService { get; set; } public bool Debugging { get; set; } @@ -63,19 +63,19 @@ public async Task InvokeAsync(InvocationContext context) var launcherConfiguration = Common.Configuration.LauncherConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(LauncherConfiguration))); - var plebianConfiguration = Configuration.PlebianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebianConfiguration))); + var plebeianConfiguration = Configuration.PlebeianConfiguration.Deserialize(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(PlebeianConfiguration))); var cashboxConfiguration = CashBoxConfigurationExt.Deserialize(await File.ReadAllTextAsync(launcherConfiguration.CashboxConfigurationFile!)); cashboxConfiguration.Decrypt(launcherConfiguration, await CommonCommandHandler.LoadCurve(launcherConfiguration.AccessToken!, launcherConfiguration.UseLegacyDataProtection!.Value)); - var packageConfiguration = (plebianConfiguration.PackageType switch + var packageConfiguration = (plebeianConfiguration.PackageType switch { PackageType.Queue => cashboxConfiguration.ftQueues, PackageType.SCU => cashboxConfiguration.ftSignaturCreationDevices, PackageType.Helper => cashboxConfiguration.helpers, var unknown => throw new Exception($"Unknown PackageType {unknown}") - }).First(p => p.Id == plebianConfiguration.PackageId); + }).First(p => p.Id == plebeianConfiguration.PackageId); packageConfiguration.Configuration = ProcessPackageConfiguration(packageConfiguration.Configuration, launcherConfiguration, cashboxConfiguration); @@ -103,7 +103,7 @@ public async Task InvokeAsync(InvocationContext context) }); services.AddSingleton(_ => launcherConfiguration); services.AddSingleton(_ => packageConfiguration); - services.AddSingleton(_ => plebianConfiguration); + services.AddSingleton(_ => plebeianConfiguration); var pluginLoader = new PluginLoader(); services.AddSingleton(_ => pluginLoader); @@ -114,7 +114,7 @@ public async Task InvokeAsync(InvocationContext context) } services.AddSingleton(); - services.AddHostedService(); + services.AddHostedService(); services.AddSingleton, DESSCDClientFactory>(); services.AddSingleton, ITSSCDClientFactory>(); diff --git a/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs b/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs index 4b250c12..473bc863 100644 --- a/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs +++ b/src/fiskaltrust.Launcher/Configuration/PlebianConfiguration.cs @@ -3,13 +3,13 @@ namespace fiskaltrust.Launcher.Configuration { - public record PlebianConfiguration + public record PlebeianConfiguration { public PackageType PackageType { get; set; } public Guid PackageId { get; set; } - public static PlebianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebianConfiguration)}"); + public static PlebeianConfiguration Deserialize(string text) => JsonSerializer.Deserialize(text, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default) as PlebeianConfiguration ?? throw new Exception($"Could not deserialize {nameof(PlebeianConfiguration)}"); - public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebianConfiguration), Helpers.Serialization.SerializerContext.Default); + public string Serialize() => JsonSerializer.Serialize(this, typeof(PlebeianConfiguration), Helpers.Serialization.SerializerContext.Default); } } diff --git a/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs b/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs index f4d67a28..3950915f 100644 --- a/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs +++ b/src/fiskaltrust.Launcher/Helpers/SerializerContext.cs @@ -3,6 +3,6 @@ namespace fiskaltrust.Launcher.Helpers.Serialization { - [JsonSerializable(typeof(PlebianConfiguration))] + [JsonSerializable(typeof(PlebeianConfiguration))] public partial class SerializerContext : JsonSerializerContext { } } \ No newline at end of file diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs index 87e0421d..e1c0768a 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostMonarch.cs @@ -27,7 +27,7 @@ public class ProcessHostMonarch : IProcessHostMonarch private readonly PackageConfiguration _packageConfiguration; private readonly ILogger _logger; - private readonly List _plebianLogBuffer = new List(); + private readonly List _plebeianLogBuffer = new List(); private LauncherConfiguration _launcherConfiguration; private PackageType _packageType; private LauncherExecutablePath _launcherExecutablePath; @@ -63,7 +63,7 @@ private void Setup() CreateNoWindow = false, Arguments = string.Join(" ", new string[] { "host", - "--plebian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"", + "--plebeian-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(new PlebeianConfiguration { PackageType = _packageType, PackageId = _packageConfiguration.Id }.Serialize()))}\"", "--launcher-configuration", $"\"{Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(_launcherConfiguration.Serialize()))}\"", }), RedirectStandardInput = true, @@ -81,7 +81,7 @@ private void ReceiveStdOut(object sender, DataReceivedEventArgs e) { if (e.Data != null) { - _plebianLogBuffer.Add(e.Data); + _plebeianLogBuffer.Add(e.Data); } } @@ -122,11 +122,11 @@ private async Task HandleExit(CancellationToken cancellationToken) if (!_started.Task.IsCompleted) { // If the process hat not signaled startup, we print the log buffer. - _logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebianLogBuffer)); - _plebianLogBuffer.Clear(); + _logger.LogError($"Error while starting {{package}} {{id}}.{Environment.NewLine}{{error}}", _packageConfiguration.Package, _packageConfiguration.Id, string.Join(Environment.NewLine, _plebeianLogBuffer)); + _plebeianLogBuffer.Clear(); } - // Plebian crash happened during the startup phase so we don't went to keep restarting. + // Plebeian crash happened during the startup phase so we don't went to keep restarting. if (!_monarchStartupCompleted) { _started.TrySetCanceled(); @@ -212,7 +212,7 @@ public void SetPlebeanStarted() _process.OutputDataReceived -= ReceiveStdOut; _process.ErrorDataReceived -= ReceiveStdOut; } - _plebianLogBuffer.Clear(); + _plebeianLogBuffer.Clear(); } public void SetStartupCompleted() diff --git a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs similarity index 89% rename from src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs rename to src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs index 256cdc76..d1b16257 100644 --- a/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebian.cs +++ b/src/fiskaltrust.Launcher/ProcessHost/ProcessHostPlebeian.cs @@ -13,24 +13,24 @@ namespace fiskaltrust.Launcher.ProcessHost { - public class ProcessHostPlebian : BackgroundService + public class ProcessHostPlebeian : BackgroundService { private readonly PackageConfiguration _packageConfiguration; private readonly IProcessHostService? _processHostService; private readonly HostingService _hosting; - private readonly PlebianConfiguration _plebianConfiguration; + private readonly PlebeianConfiguration _plebeianConfiguration; private readonly LauncherConfiguration _launcherConfiguration; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IServiceProvider _services; private readonly IHostApplicationLifetime _lifetime; - public ProcessHostPlebian(ILogger logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebianConfiguration plebianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null) + public ProcessHostPlebeian(ILogger logger, HostingService hosting, LauncherConfiguration launcherConfiguration, PackageConfiguration packageConfiguration, PlebeianConfiguration plebeianConfiguration, IServiceProvider services, IHostApplicationLifetime lifetime, IProcessHostService? processHostService = null) { _logger = logger; _hosting = hosting; _launcherConfiguration = launcherConfiguration; _packageConfiguration = packageConfiguration; - _plebianConfiguration = plebianConfiguration; + _plebeianConfiguration = plebeianConfiguration; _services = services; _processHostService = processHostService; _lifetime = lifetime; @@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) { await StartHosting(_packageConfiguration.Url); - if (_plebianConfiguration.PackageType == PackageType.Helper) + if (_plebeianConfiguration.PackageType == PackageType.Helper) { _logger.LogDebug("Helper StartBegin() and StartEnd()"); var helper = _services.GetRequiredService(); @@ -69,7 +69,7 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken) try { - if (_plebianConfiguration.PackageType == PackageType.Helper) + if (_plebeianConfiguration.PackageType == PackageType.Helper) { IHelper helper; try @@ -118,7 +118,7 @@ private async Task StartHosting(string[] uris) { var hostingFailedCompletely = uris.Length > 0; - (object instance, Action addEndpoints, Type instanceInterface) = _plebianConfiguration.PackageType switch + (object instance, Action addEndpoints, Type instanceInterface) = _plebeianConfiguration.PackageType switch { PackageType.Queue => GetQueue(_services), PackageType.SCU => GetScu(_services), @@ -140,7 +140,7 @@ private async Task StartHosting(string[] uris) try { - switch (_plebianConfiguration.PackageType) + switch (_plebeianConfiguration.PackageType) { case PackageType.SCU: if (instanceInterface == typeof(IDESSCD)) diff --git a/src/fiskaltrust.Launcher/Services/EncodingProvider.cs b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs index 8f2d7e47..3080bf5e 100644 --- a/src/fiskaltrust.Launcher/Services/EncodingProvider.cs +++ b/src/fiskaltrust.Launcher/Services/EncodingProvider.cs @@ -6,7 +6,7 @@ public class LauncherEncodingProvider : EncodingProvider { public override Encoding? GetEncoding(int codepage) => null; - // This EncodingProvider needs to be registered in the plebian processes + // This EncodingProvider needs to be registered in the plebeian processes // because ASP.NET Core uses the Encoding.GetEncoding(string) method to parse the charset of the Content-Type header. // According to the http standard (https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1) the charset may be wrapped in quotes. // Until this is fixed in ASP.NET we'll need the workaround below. diff --git a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs b/test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs similarity index 92% rename from test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs rename to test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs index 500ea873..537696ff 100644 --- a/test/fiskaltrust.Launcher.IntegrationTest/Plebian/PlebianTests.cs +++ b/test/fiskaltrust.Launcher.IntegrationTest/Plebeian/PlebeianTests.cs @@ -16,7 +16,7 @@ using System.Net; using Xunit.Abstractions; -namespace fiskaltrust.Launcher.IntegrationTest.Plebian +namespace fiskaltrust.Launcher.IntegrationTest.Plebeian { public enum Binding { @@ -26,7 +26,7 @@ public enum Binding Hostname } - public class PlebianTests + public class PlebeianTests { [SkippableTheory] [InlineData(Binding.Localhost, true, new[] { 0, 1, 2 })] @@ -37,7 +37,7 @@ public class PlebianTests [InlineData(Binding.Ip, false, new[] { 16, 17, 18 })] [InlineData(Binding.Hostname, true, new[] { 19, 20, 21 })] [InlineData(Binding.Hostname, false, new[] { 22, 23, 24 })] - public async Task PlebianScu_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) + public async Task PlebeianScu_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) { Skip.If(!OperatingSystem.IsWindows() && useHttpSysBinding, "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && useHttpSysBinding && binding is not Binding.Localhost && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -106,7 +106,7 @@ await RunTest(new DummyDeSscd(), PackageType.SCU, packageConfiguration, [InlineData(Binding.Ip, false, new[] { 40, 41, 42 })] [InlineData(Binding.Hostname, true, new[] { 43, 44, 45 })] [InlineData(Binding.Hostname, false, new[] { 46, 47, 48 })] - public async Task PlebianQueue_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) + public async Task PlebeianQueue_WithGrpcAndRestAndSoapShouldRespond(Binding binding, bool useHttpSysBinding, int[] ports) { Skip.If(!OperatingSystem.IsWindows() && useHttpSysBinding, "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && useHttpSysBinding && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -170,7 +170,7 @@ await RunTest(new DummyPos(), PackageType.Queue, packageConfiguration, use [InlineData(Binding.Loopback, 50)] [InlineData(Binding.Ip, 51)] [InlineData(Binding.Hostname, 52)] - public async Task PlebianQueue_WithSamePort(Binding binding, int port) + public async Task PlebeianQueue_WithSamePort(Binding binding, int port) { Skip.If(!OperatingSystem.IsWindows(), "HttpSysBinding is only supported on windows"); Skip.If(OperatingSystem.IsWindows() && !Runtime.IsAdministrator!.Value, $"Test needs to be run as an administrator with HttpSysBinding and {binding} binding"); @@ -230,7 +230,7 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig UseHttpSysBinding = useHttpSysBinding }; - var plebianConfiguration = new PlebianConfiguration + var plebeianConfiguration = new PlebeianConfiguration { PackageId = packageConfiguration.Id, PackageType = packageType @@ -260,8 +260,8 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig )) .Verifiable(); - var loggerProcessHostPlebian = Mock.Of>(MockBehavior.Strict); - Mock.Get(loggerProcessHostPlebian) + var loggerProcessHostPlebeian = Mock.Of>(MockBehavior.Strict); + Mock.Get(loggerProcessHostPlebeian) .Setup(x => x.Log( It.IsNotIn(new[] { LogLevel.Error, LogLevel.Critical }), It.IsAny(), @@ -272,18 +272,18 @@ private async Task RunTest(T instance, PackageType packageType, PackageConfig .Verifiable(); var hostingService = new HostingService(loggerHostingService, packageConfiguration, launcherConfiguration, processHostService); - using var plebian = new ProcessHostPlebian(loggerProcessHostPlebian, hostingService, launcherConfiguration, packageConfiguration, plebianConfiguration, services.BuildServiceProvider(), lifetime, processHostService); - await plebian.StartAsync(new CancellationToken()); + using var plebeian = new ProcessHostPlebeian(loggerProcessHostPlebeian, hostingService, launcherConfiguration, packageConfiguration, plebeianConfiguration, services.BuildServiceProvider(), lifetime, processHostService); + await plebeian.StartAsync(new CancellationToken()); if (started.Task != await Task.WhenAny(started.Task, Task.Delay(TimeSpan.FromSeconds(10)))) { - throw new TimeoutException("plebian did not start in time"); + throw new TimeoutException("plebeian did not start in time"); } await Task.Run(checks); Mock.Get(logger).Verify(x => x.Error(It.IsAny()), Times.Never); Mock.Get(loggerHostingService).Verify(); - Mock.Get(loggerProcessHostPlebian).Verify(); + Mock.Get(loggerProcessHostPlebeian).Verify(); } }