Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions app/Console/Commands/SystemMaintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class SystemMaintenance extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:system-maintenance';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Functions to keep Speedtest Tracker nice and healthy.';

/**
* Execute the console command.
*/
public function handle()
{
$this->refreshCache();

return Command::SUCCESS;
}

/**
* Clear and refresh the cache.
*/
protected function refreshCache(): void
{
Artisan::call('optimize:clear');

Artisan::call('optimize');
}
}
8 changes: 8 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console;

use App\Console\Commands\RunOoklaSpeedtest;
use App\Console\Commands\SystemMaintenance;
use App\Console\Commands\VersionChecker;
use App\Settings\GeneralSettings;
use Cron\CronExpression;
Expand All @@ -18,6 +19,13 @@ protected function schedule(Schedule $schedule): void
{
$settings = new GeneralSettings();

/**
* 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.
Expand Down