File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Health ;
4+
5+ use Laravel \Horizon \Contracts \JobRepository ;
6+ use Spatie \Health \Checks \Check ;
7+ use Spatie \Health \Checks \Result ;
8+
9+ class QueueLengthCheck extends Check
10+ {
11+ public function run (): Result
12+ {
13+ /** @var JobRepository $jobs */
14+ $ jobs = app (JobRepository::class);
15+
16+ $ result = Result::make ()
17+ ->appendMeta ([
18+ 'pending ' => $ jobs ->countPending (),
19+ 'failed ' => $ jobs ->countFailed (),
20+ 'completed ' => $ jobs ->countCompleted ()
21+ ]);
22+
23+ if ($ jobs ->countPending () > 50000 ) {
24+ return $ result
25+ ->failed ('Job queue larger than 50.000 items ' )
26+ ->shortSummary ('Excessive queue length ' );
27+ }
28+
29+ return $ result ->ok ();
30+ }
31+ }
Original file line number Diff line number Diff line change 22
33namespace App \Providers ;
44
5+ use App \Health \QueueLengthCheck ;
56use Illuminate \Support \ServiceProvider ;
67use Spatie \CpuLoadHealthCheck \CpuLoadCheck ;
78use Spatie \Health \Checks \Checks \DatabaseCheck ;
@@ -29,6 +30,7 @@ public function boot(): void
2930 UsedDiskSpaceCheck::new (),
3031 DatabaseCheck::new (),
3132 HorizonCheck::new (),
33+ QueueLengthCheck::new (),
3234 RedisCheck::new (),
3335 CpuLoadCheck::new ()
3436 ]);
Original file line number Diff line number Diff line change 211211 'environments ' => [
212212 'production ' => [
213213 'supervisor-default ' => [
214- 'maxProcesses ' => 15 ,
214+ 'maxProcesses ' => 20 ,
215215 'balanceMaxShift ' => 1 ,
216216 'balanceCooldown ' => 3 ,
217217 ],
218218 'supervisor-updates ' => [
219- 'maxProcesses ' => 40 ,
219+ 'maxProcesses ' => 80 ,
220220 'balanceMaxShift ' => 1 ,
221221 'balanceCooldown ' => 3 ,
222222 ],
Original file line number Diff line number Diff line change 88Schedule::command (CleanupSitesList::class)->everySixHours ();
99Schedule::command (PruneFailedJobsCommand::class)->daily ();
1010Schedule::command (QueueHealthChecks::class)->everyFifteenMinutes ();
11+ Schedule::command ('horizon:snapshot ' )->everyFiveMinutes ();
You can’t perform that action at this time.
0 commit comments