Skip to content

Commit

Permalink
Decorate execution of the service lifetime with logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nachtjasmin committed Oct 25, 2023
1 parent b282e63 commit 149545a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Anexia.E5E/Hosting/E5ECommunicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// If the cancellation is requested, dispose our console streams and therefore end the processing loop below.
stoppingToken.Register(_console.CloseStdin);

_logger.LogInformation("Execution started, waiting for E5E requests on standard input");
_console.Open();

// > No further services are started until ExecuteAsync becomes asynchronous, such as by calling await.
Expand All @@ -66,6 +64,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

private async Task ListenForIncomingMessagesAsync(CancellationToken stoppingToken)
{
_logger.LogInformation("Execution started, waiting for E5E requests on standard input");

while (!stoppingToken.IsCancellationRequested)
{
var line = await _console.ReadLineFromStdinAsync(stoppingToken);
Expand Down Expand Up @@ -116,6 +116,8 @@ private async Task ListenForIncomingMessagesAsync(CancellationToken stoppingToke
await _console.WriteToStdoutAsync(_options.DaemonExecutionTerminationSequence, stoppingToken);
await _console.WriteToStderrAsync(_options.DaemonExecutionTerminationSequence, stoppingToken);
}

_logger.LogInformation("Execution stopped successfully");
}

private async Task ExecuteFunctionAsync(string line, CancellationToken stoppingToken)
Expand Down

0 comments on commit 149545a

Please sign in to comment.