mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 07:06:39 +00:00
cleanup
This commit is contained in:
@@ -47,13 +47,9 @@ public class RegionProcessingService : BackgroundService
|
||||
if (workerId > 1)
|
||||
{
|
||||
var startupDelay = Random.Shared.Next(100, 500);
|
||||
_logger.LogInformation("Region worker {WorkerId} starting with {Delay}ms delay to reduce contention",
|
||||
workerId, startupDelay);
|
||||
await Task.Delay(startupDelay, stoppingToken);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Region worker {WorkerId} started", workerId);
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
@@ -62,13 +58,7 @@ public class RegionProcessingService : BackgroundService
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
_logger.LogInformation("Worker {WorkerId}: Dequeued region request {RegionId}",
|
||||
workerId, request.Id);
|
||||
|
||||
await _regionService.ProcessRegionAsync(request.Id, stoppingToken);
|
||||
|
||||
_logger.LogInformation("Worker {WorkerId}: Completed region {RegionId}",
|
||||
workerId, request.Id);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -80,8 +70,6 @@ public class RegionProcessingService : BackgroundService
|
||||
_logger.LogError(ex, "Worker {WorkerId}: Error processing region request", workerId);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Region worker {WorkerId} stopped", workerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -318,6 +318,8 @@ public class RouteProcessingService : BackgroundService
|
||||
|
||||
await _routeRepository.UpdateRouteAsync(route);
|
||||
|
||||
await CleanupRegionFilesAsync(regionIds, cancellationToken);
|
||||
|
||||
_logger.LogInformation("Route {RouteId} maps processing completed successfully", routeId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -327,6 +329,53 @@ public class RouteProcessingService : BackgroundService
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CleanupRegionFilesAsync(IEnumerable<Guid> regionIds, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var regionId in regionIds)
|
||||
{
|
||||
var region = await _regionRepository.GetByIdAsync(regionId);
|
||||
if (region == null) continue;
|
||||
|
||||
if (!string.IsNullOrEmpty(region.CsvFilePath) && File.Exists(region.CsvFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(region.CsvFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region CSV file: {FilePath}", region.CsvFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(region.SummaryFilePath) && File.Exists(region.SummaryFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(region.SummaryFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region summary file: {FilePath}", region.SummaryFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
var readyDir = _storageConfig.ReadyDirectory;
|
||||
var stitchedImagePath = Path.Combine(readyDir, $"region_{regionId}_stitched.jpg");
|
||||
if (File.Exists(stitchedImagePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(stitchedImagePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete region stitched image: {FilePath}", stitchedImagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GenerateRouteCsvAsync(
|
||||
string filePath,
|
||||
IEnumerable<TileInfo> tiles,
|
||||
|
||||
Reference in New Issue
Block a user