refactor(time): change DateTime from UTC to local time
- Change HealthCheckHtmlGenerator to use DateTime.Now instead of DateTime.UtcNow - Change ProfileWorker health check timestamps to use DateTime.Now - Change Program health check endpoint to use DateTime.Now - Ensures consistent local time usage across the application
This commit is contained in:
@@ -112,7 +112,7 @@ public static class HealthCheckHtmlGenerator
|
||||
<h1 class=""mb-2"">");
|
||||
sb.Append(icon);
|
||||
sb.Append($@" Health Check Status</h1>
|
||||
<p class=""text-muted mb-0"">Last checked: {DateTime.UtcNow:yyyy-MM-dd HH:mm:ss} UTC</p>
|
||||
<p class=""text-muted mb-0"">Last checked: {DateTime.Now:yyyy-MM-dd HH:mm:ss} UTC</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2><span class=""badge {badgeClass} fs-3"">{report.Status}</span></h2>
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ProfileWorker(
|
||||
await work.ExecuteAsync(stoppingToken);
|
||||
|
||||
// Success - update health state
|
||||
_lastSuccessfulRun = DateTime.UtcNow;
|
||||
_lastSuccessfulRun = DateTime.Now;
|
||||
_consecutiveFailures = 0;
|
||||
_lastException = null;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class ProfileWorker(
|
||||
));
|
||||
}
|
||||
|
||||
var timeSinceLastSuccess = DateTime.UtcNow - _lastSuccessfulRun.Value;
|
||||
var timeSinceLastSuccess = DateTime.Now - _lastSuccessfulRun.Value;
|
||||
|
||||
// Adaptive multiplier: 3x for fast intervals (<10s), 1.5x for slower intervals
|
||||
// This ensures faster problem detection when using longer intervals (e.g., 60s)
|
||||
|
||||
@@ -2,6 +2,7 @@ using ECMJobRunner.Application;
|
||||
using ECMJobRunner.Infrastructure;
|
||||
using ECMJobRunner.WebCron;
|
||||
using ECMJobRunner.WebCron.HealthCheck;
|
||||
using ECMJobRunner.WebCron.Middleware;
|
||||
using ECMJobRunner.WebCron.ProfileWorker;
|
||||
using Hangfire;
|
||||
using Hangfire.SqlServer;
|
||||
@@ -65,7 +66,7 @@ builder.Services.AddJobRunnerInfrastructure(cnnStr);
|
||||
|
||||
var recClientApiUrl = builder.Configuration.GetValue<string>("ReC:ApiUrl")
|
||||
?? throw new InvalidOperationException("ReC:ApiUrl not found.");
|
||||
builder.Services.AddJobRunnerServices(recClientApiUrl);
|
||||
builder.Services.AddJobRunnerServices(recClientApiUrl, builder.Configuration);
|
||||
|
||||
// Get Hangfire storage configuration
|
||||
var useInMemory = builder.Configuration.GetValue<bool>("Hangfire:InMemory");
|
||||
@@ -105,7 +106,7 @@ builder.Services.AddSwaggerGen();
|
||||
|
||||
// Add health checks
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck<ProfileWorker>("profile-worker", tags: new[] { "ready", "worker" });
|
||||
.AddCheck<ProfileWorker>("profile-worker", tags: ["ready", "worker"]);
|
||||
|
||||
// Add Serilog.UI with SQLite provider - use same path from configuration
|
||||
var serilogUiLogDirectory = builder.Configuration.GetValue<string>("Application:LogDirectory")
|
||||
@@ -123,6 +124,8 @@ builder.Services.AddSerilogUi(logUIOpt =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
@@ -171,7 +174,7 @@ app.MapHealthChecks("/health", new Microsoft.AspNetCore.Diagnostics.HealthChecks
|
||||
var result = System.Text.Json.JsonSerializer.Serialize(new
|
||||
{
|
||||
status = report.Status.ToString(),
|
||||
timestamp = DateTime.UtcNow,
|
||||
timestamp = DateTime.Now,
|
||||
checks = report.Entries.Select(e => new
|
||||
{
|
||||
name = e.Key,
|
||||
|
||||
Reference in New Issue
Block a user