forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKernel.php
More file actions
70 lines (60 loc) · 2.06 KB
/
Kernel.php
File metadata and controls
70 lines (60 loc) · 2.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace App\Console;
use App\Console\Commands\RunOoklaSpeedtest;
use App\Console\Commands\SystemMaintenance;
use App\Console\Commands\VersionChecker;
use App\Models\Result;
use App\Settings\GeneralSettings;
use Cron\CronExpression;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
$settings = new GeneralSettings();
/**
* Checks if Result model records should be pruned.
*/
if ($settings->prune_results_older_than > 0) {
$schedule->command('model:prune', [
'--model' => [Result::class],
])->daily();
}
/**
* Perform system maintenance weekly on Sunday morning,
* start off the week nice and fresh.
*/
$schedule->command(SystemMaintenance::class)->weeklyOn(0)
->timezone($settings->timezone ?? 'UTC');
/**
* Checked for new versions weekly on Thursday because
* I usually do releases on Thursday or Friday.
*/
$schedule->command(VersionChecker::class)->weeklyOn(5)
->timezone($settings->timezone ?? 'UTC');
/**
* Check if an Ookla Speedtest needs to run.
*/
$schedule->command(RunOoklaSpeedtest::class, ['--scheduled'])->everyMinute()
->timezone($settings->timezone ?? 'UTC')
->when(function () use ($settings) {
if (blank($settings->speedtest_schedule)) {
return false;
}
return (new CronExpression($settings->speedtest_schedule))
->isDue(now()->timezone($settings->timezone ?? 'UTC'));
});
}
/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}