Schedule Check
Schedule Check
Checks for a heartbeat timestamp in cache to verify the scheduler is active.
Configuration
'checks_config' => [
'schedule' => ['max_age_minutes' => 5],
],
Setup
Schedule the built-in heartbeat command in your routes/console.php:
use Illuminate\Support\Facades\Schedule;
Schedule::command('health:heartbeat')->everyMinute();
Or if you prefer a manual approach:
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schedule;
Schedule::call(function () {
Cache::put('health:schedule:heartbeat', now(), 600);
})->everyMinute();
Usage
use Cbox\LaravelHealth\Checks\ScheduleCheck;
'checks' => [
'readiness' => [
ScheduleCheck::class,
],
],
Behavior
- Reads the heartbeat timestamp from cache
- Returns
warningif no heartbeat is found - Returns
criticalif the heartbeat is older thanmax_age_minutes - Returns
okwhen the heartbeat is fresh - Includes
age_minutesandmax_age_minutesin metadata