Skip to content

Commit

Permalink
Merge pull request #96 from clearlydefined/roman/pjc_fix
Browse files Browse the repository at this point in the history
Fix #95
  • Loading branch information
RomanIakovlev authored Oct 3, 2024
2 parents bb29bc7 + 12d345d commit 89e3f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
5 changes: 3 additions & 2 deletions tools/blobstorage-backupdata/BackupData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartupObject>BackupData.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.8.2" />
<PackageReference Include="Azure.Identity" Version="1.12.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.0" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.0" />
Expand Down
2 changes: 1 addition & 1 deletion tools/blobstorage-backupdata/BackupJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed class BackupJob
private static readonly object LockObject = new();
private static int counter;
private const string DateTimeFormat = "yyyy-MM-dd-HH";
private const int BatchSize = 10000;
private const int BatchSize = 1000;
private const string UpdatedFieldName = "_meta.updated";
private const string MetaFieldName = "_meta";

Expand Down
4 changes: 2 additions & 2 deletions tools/blobstorage-backupdata/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Use the official image as a parent image
FROM mcr.microsoft.com/dotnet/runtime:7.0-alpine AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base
LABEL org.opencontainers.image.source="https://github.com/clearlydefined/operations"
LABEL org.opencontainers.image.description="ClearlyDefined publish changes job"
WORKDIR /app

# Use the SDK image to build the app
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
WORKDIR /src
COPY ["BackupData.csproj", "BackupData/"]
RUN dotnet restore "BackupData/BackupData.csproj"
Expand Down
14 changes: 4 additions & 10 deletions tools/blobstorage-backupdata/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@

internal sealed class Program
{
internal static void Main()
internal static async Task Main()
{
DotNetEnv.Env.Load();
string? useJsonLoggingEnvVar = Environment.GetEnvironmentVariable("USE_JSON_LOGGING");
_ = bool.TryParse(useJsonLoggingEnvVar, out bool useJsonLogging);
using ILoggerFactory loggerFactory = CustomLoggerFactory.Create(useJsonLogging);

ILogger logger = loggerFactory.CreateLogger(nameof(Program));
logger.LogInformation("Backup job started.");
var backupJob = CreateBackupJob(loggerFactory);
try
{
backupJob.ProcessJob().Wait();
}
catch (AggregateException ae)
{
foreach (var e in ae.InnerExceptions)
{
logger.LogError(e, "Backup job failed.");
}
var backupJob = CreateBackupJob(loggerFactory);
await backupJob.ProcessJob();
}
catch (Exception e)
{
Expand Down

0 comments on commit 89e3f89

Please sign in to comment.