Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #270 from abpframework/EShopOnAbpHealthCheck
Browse files Browse the repository at this point in the history
Use `IAbpApplicationConfigurationAppService` to check website health.
  • Loading branch information
skoc10 authored Oct 31, 2024
2 parents 1e64a58 + aa004c5 commit f48ef18
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;

namespace EShopOnAbp.PublicWeb.HealthChecks;

public class EShopOnAbpHealthCheck : IHealthCheck, ITransientDependency
{
protected readonly IIdentityUserAppService IdentityUserAppService;
protected readonly IAbpApplicationConfigurationAppService ApplicationConfigurationAppService;

public EShopOnAbpHealthCheck(IIdentityUserAppService identityUserAppService)
public EShopOnAbpHealthCheck(IAbpApplicationConfigurationAppService applicationConfigurationAppService)
{
IdentityUserAppService = identityUserAppService;
ApplicationConfigurationAppService = applicationConfigurationAppService;
}

public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
await IdentityUserAppService.GetListAsync(new GetIdentityUsersInput { MaxResultCount = 1 });
await ApplicationConfigurationAppService.GetAsync(new ApplicationConfigurationRequestOptions()
{
IncludeLocalizationResources = false
});

return HealthCheckResult.Healthy($"Could connect to database and get record.");
}
Expand Down

0 comments on commit f48ef18

Please sign in to comment.