-
Notifications
You must be signed in to change notification settings - Fork 629
/
SnapshotCommand.php
40 lines (34 loc) · 965 Bytes
/
SnapshotCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Laravel\Horizon\Console;
use Illuminate\Console\Command;
use Laravel\Horizon\Contracts\MetricsRepository;
use Laravel\Horizon\Lock;
class SnapshotCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'horizon:snapshot';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Store a snapshot of the queue metrics';
/**
* Execute the console command.
*
* @param \Laravel\Horizon\Lock $lock
* @param \Laravel\Horizon\Contracts\MetricsRepository $metrics
* @return void
*/
public function handle(Lock $lock, MetricsRepository $metrics)
{
if ($lock->get('metrics:snapshot', config('horizon.metrics.snapshot_lock', 300))) {
$metrics->snapshot();
$this->info('Metrics snapshot stored successfully.');
}
}
}