Skip to content

Commit 6179862

Browse files
ArneDrikdepeuter
authored andcommitted
fix(tools): stop console when service is done
1 parent 4dc745f commit 6179862

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/BuildingRegistry.Tools.Console/RepairBuilding/RepairBuildingService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class RepairBuildingService : BackgroundService
1818
private readonly ITicketing _ticketing;
1919
private readonly ProjectionRepository _projectionRepository;
2020
private readonly INotificationService _notificationService;
21+
private readonly IHostApplicationLifetime _hostApplicationLifetime;
2122
private readonly ILogger<RepairBuildingService> _logger;
2223

2324
public RepairBuildingService(
@@ -26,13 +27,15 @@ public RepairBuildingService(
2627
ITicketing ticketing,
2728
ProjectionRepository projectionRepository,
2829
INotificationService notificationService,
30+
IHostApplicationLifetime hostApplicationLifetime,
2931
ILoggerFactory loggerFactory)
3032
{
3133
_sqsRateLimiter = sqsRateLimiter;
3234
_repairBuildingRepository = repairBuildingRepository;
3335
_ticketing = ticketing;
3436
_projectionRepository = projectionRepository;
3537
_notificationService = notificationService;
38+
_hostApplicationLifetime = hostApplicationLifetime;
3639
_logger = loggerFactory.CreateLogger<RepairBuildingService>();
3740
}
3841

@@ -62,11 +65,13 @@ await _sqsRateLimiter.Handle<int>(
6265
stoppingToken);
6366

6467
_logger.LogInformation("Building repair processing completed.");
68+
69+
_hostApplicationLifetime.StopApplication();
6570
}
6671

6772
private async Task WaitIfProducerProjectionBehindAsync(CancellationToken cancellationToken)
6873
{
69-
while (true)
74+
while (!cancellationToken.IsCancellationRequested)
7075
{
7176
var producerPosition = await _projectionRepository.GetProducerPosition();
7277
var headPosition = await _projectionRepository.GetMaxAllStreamPosition();

0 commit comments

Comments
 (0)