Monitor your Laravel scheduled commands with Laravel Forge Heartbeats.
This package automatically syncs your Laravel scheduled commands with Forge heartbeats and pings them when tasks run.
- No Database Required - Everything managed through Forge API
- Automatic Sync - Keep heartbeats in sync with your schedule
- Automatic Pinging - Tasks ping heartbeats when they run
- Queue Support - Non-blocking heartbeat pings via queues
Note: this package is not ready yet. Forge v2 API is still in beta and behind a feature flag.
You can install the package via Composer:
composer require srwiez/forge-heartbeats- API Token: Generate in your Forge dashboard (https://forge.laravel.com/profile/api). You need at least
site:manage-heartbeatsandserver:viewpermission for this package. - Organization: Look for the slug in the URL when viewing your organization (e.g.,
my-orginhttps://forge.laravel.com/your-organization/) - Server ID: Found in the server homepage
- Site ID: Found in the site homepage
Add these environment variables to your .env file:
FORGE_API_TOKEN=your_forge_api_token_here
FORGE_ORGANIZATION=your_organization_slug
FORGE_SERVER_ID=12345
FORGE_SITE_ID=67890
# Optional: Default grace period for heartbeats (default: 5 minutes)
FORGE_HEARTBEAT_GRACE_PERIOD=5
# Optional: Custom cache store for heartbeat data (default: uses Laravel's default cache)
FORGE_HEARTBEAT_CACHE_STORE=redisFor more configuration options, publish the config file:
php artisan vendor:publish --tag="forge-heartbeats-config"Test your Forge connection:
php artisan forge-heartbeats:verifyThen view the status of all your heartbeats:
php artisan forge-heartbeats:listThis should run after every deployment to keep heartbeats up to date.
php artisan forge-heartbeats:syncThis command will:
- Create heartbeats for new scheduled tasks
- Update existing heartbeats if changed
- Remove heartbeats for deleted tasks (unless
--keep-old)
Add heartbeat configuration to your scheduled tasks:
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
// Basic task - uses command name as heartbeat name
$schedule->command('backup:run')->daily();
// Custom heartbeat name
$schedule->command('reports:generate')
->hourly()
->heartbeatName('hourly-reports');
// Custom grace period (time allowed for task to complete)
$schedule->command('sync:users')
->daily()
->heartbeatName('user-sync')
->graceTimeInMinutes(30);
// Skip monitoring for specific tasks
$schedule->command('cache:clear')
->everyMinute()
->doNotMonitorOnForge();
}The MIT License (MIT). Please see License File for more information.