Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Ardal 3 posts 73 karma points c-trib
    Nov 22, 2019 @ 11:54
    Thomas Ardal
    0

    Building custom health check notification methods

    I'm trying to build a custom health check notification method. There is some documentation available here which is fine, but not ported for Umbraco 8 (as it is stated in the doc). I'm looking at EmailNotificationMethod and trying to do something similar. I have a very simple notification method:

    [HealthCheckNotificationMethod("minimal")]
    public class MinimalNotificationMethod : NotificationMethodBase
    {
        public MinimalNotificationMethod()
        {
        }
    
        public override async Task SendAsync(HealthCheckResults results, CancellationToken token)
        {
        }
    }
    

    And I'm configuring it in the HealthChecks.config file:

    <HealthChecks>
      <notificationSettings enabled="true" firstRunTime="" periodInHours="24">
        <notificationMethods>
          <notificationMethod alias="minimal" enabled="true" verbosity="Summary">
          </notificationMethod>
          <notificationMethod alias="email" enabled="false" verbosity="Summary">
            <settings>
              <add key="recipientEmail" value="" />
            </settings>
          </notificationMethod>
        </notificationMethods>
      </notificationSettings>
    </HealthChecks>
    

    (don't really want the email method in there, but Umbraco crashes if not there why I disabled it)

    When starting the site, the debugger breaks inside the constructor of MinimalNotificationMethod. But it never breaks inside the SendAsync method.

    I have set umbracoApplicationUrl to https://localhost:44327/umbraco/ in the umbracoSettings.config file as stated in the docs.

    I'm on Umbraco 8.3 but I had the same problem in 8.0. What could be the problem here?

  • Thomas Ardal 3 posts 73 karma points c-trib
    Jan 27, 2020 @ 12:07
    Thomas Ardal
    0

    I managed to find out what is going on here. For future questions around the same topic, here's the explanation.

    The issue is caused by two different things.

    1. The documentation states that If firstRunTime is empty, the tests will run for the first time right after the application is started.. I read this as if the check would run a few seconds after the startup of the application. In reality, there's a timeout period of 180.000 ms (3 minutes) before automatic health checks are run the first time.

    2. For some reason my site was marked with ServerRole.Unknown. Health checks are not automatically executed if server role is unknown (or replica). When launching my project now, the server role is Single and the publisher is executed. I don't know enough about this to say why it was marked as Unknown in the first place.

Please Sign in or register to post replies

Write your reply to:

Draft