Piranha CMS Setup HealthChecks

74 views Asked by At

I'm trying to setup HealthCheck's with Piranha CMS. These work fine locally, but once I deploy the endpoints give an 500 internal error. Is there something I am missing with registering HealthCheck's with Piranha CMS. I've tried moving these into the app.UsePiranha(options => and services.AddPiranha(options =>, but still cannot access the HealthCheck endpoints.

Both of these are above the piranha registration.

    services.AddHealthChecks()
          .AddCheck<DealerUserSyncHealthCheck>("DealerSync Health Check", null, new[] { "DealerSync" })
          .AddCheck<VendorSyncHealthCheck>("VendorSync Health Check", null, new[] { "VendorSync" })
          .AddCheck<ContactUserSyncHealthCheck>("ContactUserSync Health Check", null, new[] { "ContactUserSync" })
          .AddCheck<DbHealthCheck>("Db Health Check", null, new[] { "Db" })
          .AddCheck<SendGridHealthCheck>("SendGrid Health Check", null, new[] { "SendGrid" })
          .AddCheck<RedisHealthCheck>("Redis Health Check", null, new[] { "Redis" });

  OBESettings settings = new OBESettings();
        Configuration.Bind(settings);

        // Setup Health Check Endpoints
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHealthChecks("/DealerSyncCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("DealerSync")
            });//.RequireHost(settings.HealthCheckWhitelist);
            endpoints.MapHealthChecks("/VendorSyncCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("VendorSync")
            });//.RequireHost(settings.HealthCheckWhitelist);
            endpoints.MapHealthChecks("/ContactUserSyncCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("ContactUserSync")
            });//.RequireHost(settings.HealthCheckWhitelist);
            endpoints.MapHealthChecks("/DbCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("Db")
            });//.RequireHost(settings.HealthCheckWhitelist);
            endpoints.MapHealthChecks("/SendGridCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("SendGrid")
            });//.RequireHost(settings.HealthCheckWhitelist);
            endpoints.MapHealthChecks("/RedisCheck", new HealthCheckOptions
            {
                Predicate = healthCheck => healthCheck.Tags.Contains("Redis")
            });//.RequireHost(settings.HealthCheckWhitelist);

        });
1

There are 1 answers

0
Jesse On BEST ANSWER

I've since moved the healthcheck registration above services.AddPiranha and app.UsePiranha registration. I've had to add back in a call to services.AddControllers(); for ConfigureServices and app.UseRouting(); for Configure. Everything now works when deployed.