lasthourcloud/app/Console/Kernel.php

64 lines
2.2 KiB
PHP
Raw Normal View History

2023-03-17 14:33:48 +00:00
<?php
namespace App\Console;
2023-08-08 15:28:36 +00:00
use App\Jobs\BackupDatabaseJob;
2023-07-14 09:27:08 +00:00
use App\Jobs\CheckResaleLicenseJob;
use App\Jobs\CheckResaleLicenseKeys;
use App\Jobs\DockerCleanupJob;
use App\Jobs\InstanceApplicationsStatusJob;
2023-05-25 12:23:49 +00:00
use App\Jobs\InstanceAutoUpdateJob;
2023-07-07 13:50:36 +00:00
use App\Jobs\ProxyCheckJob;
2023-08-08 15:28:36 +00:00
use App\Models\ScheduledDatabaseBackup;
2023-03-17 14:33:48 +00:00
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule): void
{
2023-08-08 15:28:36 +00:00
// $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds();
2023-06-16 09:01:27 +00:00
if (isDev()) {
2023-06-06 06:43:01 +00:00
$schedule->command('horizon:snapshot')->everyMinute();
$schedule->job(new InstanceApplicationsStatusJob)->everyMinute();
2023-07-14 11:03:58 +00:00
$schedule->job(new ProxyCheckJob)->everyFiveMinutes();
2023-08-08 15:28:36 +00:00
2023-07-14 09:33:08 +00:00
// $schedule->job(new CheckResaleLicenseJob)->hourly();
// $schedule->job(new DockerCleanupJob)->everyOddHour();
2023-06-15 09:23:48 +00:00
// $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute();
2023-06-06 06:43:01 +00:00
} else {
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new InstanceApplicationsStatusJob)->everyMinute();
2023-07-14 09:33:08 +00:00
$schedule->job(new CheckResaleLicenseJob)->hourly();
2023-07-07 13:50:36 +00:00
$schedule->job(new ProxyCheckJob)->everyFiveMinutes();
2023-07-07 19:35:29 +00:00
$schedule->job(new DockerCleanupJob)->everyTenMinutes();
2023-06-15 09:23:48 +00:00
$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
2023-06-06 06:43:01 +00:00
}
2023-08-08 15:28:36 +00:00
$this->check_scheduled_backups($schedule);
}
private function check_scheduled_backups($schedule)
{
ray('check_scheduled_backups');
$scheduled_backups = ScheduledDatabaseBackup::all();
if ($scheduled_backups->isEmpty()) {
ray('no scheduled backups');
return;
}
foreach ($scheduled_backups as $scheduled_backup) {
if (!$scheduled_backup->enabled) continue;
$schedule->job(new BackupDatabaseJob(
backup: $scheduled_backup
))->cron($scheduled_backup->frequency);
}
2023-03-17 14:33:48 +00:00
}
2023-03-17 14:33:48 +00:00
protected function commands(): void
{
2023-04-28 07:00:47 +00:00
$this->load(__DIR__ . '/Commands');
2023-03-17 14:33:48 +00:00
require base_path('routes/console.php');
}
2023-07-14 09:27:08 +00:00
}