Custom Health Checks
Using Laritor, You can define and monitor custom health checks or queue worker health checks.
Creating Custom Health Checks
Section titled “Creating Custom Health Checks”To get started with custom health checks, Run
php artisan make:laritor-custom-hc PaymentProviderHealthCheck
This command will create a new health check file called PaymentProviderHealthCheck.php
in your app/Laritor/
directory.
The file contents are as below.
<?php
namespace App\Laritor;
use BinaryBuilds\LaritorClient\Checks\BaseHealthCheck;use Illuminate\Http\Request;
class PaymentProviderHealthCheck extends BaseHealthCheck{ /** * @var string */ public static $name = 'Payment Provider Health Check';
/** * @return bool */ public function check(Request $request) { return true; }
/** * @return string */ public function successMessage() { return 'heath check successful'; }
/** * @return string */ public function failureMessage() { return 'health check failed'; }}
Update the check
method to write your custom health check code and return true for success and false for failure.
public function check(Request $request){ // Your custom health check code goes here return true;}
Optionally, You can update the successMessage
and failureMessage
methods to use your own success and failure messages.
Creating Queue Health Checks
Section titled “Creating Queue Health Checks”Laritor by default comes with a queue worker health check which monitors your default connection and queue. If you wish to monitor other connections or queues, you can define a queue health check.
To get started with queue health checks, Run
php artisan make:laritor-queue-hc HighPriorityQueueHealthCheck
This command will create a new health check file called HighPriorityQueueHealthCheck.php
in your app/Laritor/
directory.
The file contents are as below.
<?php
namespace App\Laritor;
use BinaryBuilds\LaritorClient\Checks\QueueWorkerHealthCheck;use Illuminate\Http\Request;
class HighPriorityQueueHealthCheck extends QueueWorkerHealthCheck{ public static $name = 'High Priority Queue Health Check';
/** * Add a queue connection name to monitor. Leave null if you wish to use default connection. * @var string|null */ public $connection = null;
/** * Add a queue name to monitor. Leave null if you wish to use default queue. * @var string|null */ public $queue = null;}
Override $connection
and $queue
properties with your connection and queue names.
Synchronizing Health Checks With Laritor
Section titled “Synchronizing Health Checks With Laritor”There is no need to synchronize custom health checks separately. If you are running php artisan laritor:sync
command
as part of your deployment process, It will automatically track
your custom health checks and sync with laritor upon next deployment.
Health Checks Schedule
Section titled “Health Checks Schedule”By Default, All custom health checks will be scheduled to run every five minutes. After the health checks are synchronized with laritor, You may override the schedule from the laritor dashboard.