Download the PHP package cronpulse/laravel-monitor without Composer
On this page you can find all versions of the php package cronpulse/laravel-monitor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cronpulse/laravel-monitor
More information about cronpulse/laravel-monitor
Files in cronpulse/laravel-monitor
Package laravel-monitor
Short Description A cronjob monitoring library for Laravel using Cronpulse.live
License
Informations about the package laravel-monitor
Cronpulse Laravel Monitor
Cronpulse Laravel Monitor is a monitoring library for Laravel applications that allows you to easily send heartbeat pings, start/stop job pings, and wrap jobs for monitoring. This helps ensure your scheduled tasks are running as expected and provides insights into job failures or successes.
Installation
To install the package, add it to your Laravel project's composer.json
and run composer update
:
Configuration
After installation, publish the configuration file:
Add your job key to your .env
file:
This job key is essential for authenticating your pings with cronpulse.
Usage
Basic Monitoring
You can manually ping cronpulse by using the Monitor
class. This can be useful for sending status updates about your scheduled jobs.
Starting a Job
To start monitoring a job:
Marking a Job as Successful
After your job completes successfully:
Marking a Job as Failed
If your job encounters an error and fails:
Sending Heartbeat Pings
You can also send heartbeat pings to monitor the regular execution of a task:
Wrapping a Job
The wrap
function provides a convenient way to monitor a job's start and completion, including error handling.
Example with a Successful Job
To wrap a job function that should complete successfully:
Example with a Failing Job
To wrap a job function that might fail:
The wrap
function will automatically handle sending pings for the job start, success, or failure.
Testing
The library includes tests to ensure its functionality. You can run the tests using Laravel’s test runner:
Ensure that your .env
file contains the correct MONITOR_JOB_KEY
for the tests to run against your monitoring service.