Skip to content

Health checks in VirtoCommerce platform

VirtoCommerce platform support health checks from ASP.NET Core middlewares.

Adding heal checks in modules

Create class wich inherits from IHealthCheck interface. Implement it.


public class CatalogHealthCheck : IHealthCheck
    public Task<HealthCheckResult> CheckHealthAsync(
        HealthCheckContext context,
        CancellationToken cancellationToken = default(CancellationToken))
        var healthCheckResultHealthy = true;

        if (healthCheckResultHealthy)
            return Task.FromResult(
                HealthCheckResult.Healthy("A healthy result."));

        return Task.FromResult(
            new HealthCheckResult(context.Registration.FailureStatus,
            "An unhealthy result."));

Register created health checks in service collection.


public class Module : IModule
    public void Initialize(IServiceCollection serviceCollection)
        //Rest of code skipped for better clarity



3. Done

Now you can check your platform by getting a response from /health endpoint.



Docker offers a built-in HEALTHCHECK directive that can be used to check the status of an app that uses the basic health check configuration:

HEALTHCHECK CMD curl --fail http://localhost:5000/health || exit

Additional Resources


Last update: June 23, 2021