In this episode, we're taking the next step by not only detecting when an endpoint goes down, but also when it comes back up—basically, we're setting up a recovery notification system.
We start by updating our logic to detect when an endpoint that was previously down becomes available again. This involves adding a few new checks to our code to avoid spamming users with recovery notifications every time a successful check happens—only the first successful check after downtime should trigger an email.
From there, we jump into Laravel and create the necessary event (EndpointRecovered
), listener, and notification. The process is super similar to how we handled downtime notifications, so there's a bit of code copying (with some tweaks). We set up everything from the backend logic to the email view that the users will see.
Next, we do some actual testing by triggering downtime and recovery, making sure emails are sent at the right times. Along the way, we hit a couple of bugs (always fun!), and we fix them—like remembering to dispatch the event and pass the correct properties. We also look at the failed jobs table to help debug what's going wrong.
Finally, once everything works, we take a quick look at making our email notifications friendlier using Laravel's Markdown email functionality to clean up the format. By the end of this episode, we've got a robust notification system that avoids duplicate emails and lets users know exactly when their endpoints are back online!