diff --git a/README.md b/README.md index 534ccddf..e20b7125 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ services: volumes: - ./cleanuperr/logs:/var/logs environment: + - TZ=America/New_York - DRY_RUN=false - LOGGING__LOGLEVEL=Information diff --git a/code/Executable/HostExtensions.cs b/code/Executable/HostExtensions.cs new file mode 100644 index 00000000..42e1a70e --- /dev/null +++ b/code/Executable/HostExtensions.cs @@ -0,0 +1,23 @@ +using System.Reflection; + +namespace Executable; + +public static class HostExtensions +{ + public static IHost Init(this IHost host) + { + ILogger logger = host.Services.GetRequiredService>(); + + Version? version = Assembly.GetExecutingAssembly().GetName().Version; + + logger.LogInformation( + version is null + ? "cleanuperr version not detected" + : $"cleanuperr v{version.Major}.{version.Minor}.{version.Build}" + ); + + logger.LogInformation("timezone: {tz}", TimeZoneInfo.Local.Id); + + return host; + } +} \ No newline at end of file diff --git a/code/Executable/Program.cs b/code/Executable/Program.cs index c7b41576..5623667f 100644 --- a/code/Executable/Program.cs +++ b/code/Executable/Program.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using Executable; using Executable.DependencyInjection; var builder = Host.CreateApplicationBuilder(args); @@ -7,15 +7,6 @@ builder.Services.AddInfrastructure(builder.Configuration); builder.Logging.AddLogging(builder.Configuration); var host = builder.Build(); - -var logger = host.Services.GetRequiredService>(); - -var version = Assembly.GetExecutingAssembly().GetName().Version; - -logger.LogInformation( - version is null - ? "cleanuperr version not detected" - : $"cleanuperr v{version.Major}.{version.Minor}.{version.Build}" -); +host.Init(); host.Run(); \ No newline at end of file diff --git a/code/test/docker-compose.yml b/code/test/docker-compose.yml index be1f2342..010531d7 100644 --- a/code/test/docker-compose.yml +++ b/code/test/docker-compose.yml @@ -175,6 +175,7 @@ services: image: ghcr.io/flmorg/cleanuperr:latest container_name: cleanuperr environment: + - TZ=Europe/Bucharest - DRY_RUN=false - LOGGING__LOGLEVEL=Debug diff --git a/variables.md b/variables.md index 8d64c038..dcd07cef 100644 --- a/variables.md +++ b/variables.md @@ -12,6 +12,13 @@ ### General settings +**`TZ`** +- The time zone to use. +- Type: String. +- Possible values: Any valid timezone. +- Default: `UTC`. +- Required: No. + **`DRY_RUN`** - When enabled, simulates irreversible operations (like deletions and notifications) without making actual changes. - Type: Boolean.