srwiez/forge-heartbeats
最新稳定版本:v1.1.0
Composer 安装命令:
composer require srwiez/forge-heartbeats
包简介
Monitor Laravel scheduled tasks with Laravel Forge Heartbeats API
README 文档
README
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.
🚀 Installation
You can install the package via Composer:
composer require srwiez/forge-heartbeats
📚 Usage
1. Get your credentials
- 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
2. Set environment variables
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=redis
For more configuration options, publish the config file:
php artisan vendor:publish --tag="forge-heartbeats-config"
3. Verify your configuration
Test your Forge connection:
php artisan forge-heartbeats:verify
Then view the status of all your heartbeats:
php artisan forge-heartbeats:list
4. Sync Your Schedule
This should run after every deployment to keep heartbeats up to date.
php artisan forge-heartbeats:sync
This command will:
- Create heartbeats for new scheduled tasks
- Update existing heartbeats if changed
- Remove heartbeats for deleted tasks (unless
--keep-old)
5. Customize Your Tasks
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(); }
👥 Credits
📝 License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 191
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-05