Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions src/Particular.PlatformSample/AppLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ sealed class AppLauncher(bool showPlatformToolConsoleOutput) : IAsyncDisposable
readonly bool hideConsoleOutput = !showPlatformToolConsoleOutput;
readonly Stack<Func<ValueTask>> cleanupActions = new();
readonly List<PlatformTool> platformTools = [];
volatile bool captureErrorOutput = true;

public sealed record PlatformTool(string Name, Process Process, StringBuilder ErrorOutput);

// The error output is only needed to report a startup failure, so stop keeping it once startup succeeds
public void StopCapturingErrorOutput() => captureErrorOutput = false;

public void StopProcesses()
{
foreach (var tool in platformTools)
Expand Down Expand Up @@ -220,10 +224,11 @@ void StartProcess(string name, string assemblyPath, Dictionary<string, string> e
// without this in certain occasions the start takes waaaaay longer!
if (hideConsoleOutput)
{
// Keep the hidden error output so it can be shown if the tool fails to start
// Keep the hidden error output so it can be shown if the tool fails to start.
// The stream is still read after capturing stops, otherwise the tool blocks once the pipe buffer is full.
process.ErrorDataReceived += (_, args) =>
{
if (args.Data is not null)
if (args.Data is not null && captureErrorOutput)
{
tool.ErrorOutput.AppendLine(args.Data);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Particular.PlatformSample/PlatformLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ await Network.WaitForHttpOk($"http://localhost:{controlPort}/api", stopWaiting:
return;
}

launcher.StopCapturingErrorOutput();

if (!tokenSource.IsCancellationRequested)
{
var serviceControlApiUrl = $"http://localhost:{controlPort}/api";
Expand Down
Loading