2017-06-09 02:28:26 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console;
|
|
|
|
|
2022-02-12 05:24:06 +08:00
|
|
|
use App\Console\Cron\FifteenMinute;
|
|
|
|
use App\Console\Cron\FiveMinute;
|
2018-08-25 01:07:14 +08:00
|
|
|
use App\Console\Cron\Hourly;
|
2021-05-20 23:54:07 +08:00
|
|
|
use App\Console\Cron\JobQueue;
|
2018-03-17 09:12:56 +08:00
|
|
|
use App\Console\Cron\Monthly;
|
|
|
|
use App\Console\Cron\Nightly;
|
2022-02-12 05:24:06 +08:00
|
|
|
use App\Console\Cron\ThirtyMinute;
|
2018-03-17 09:12:56 +08:00
|
|
|
use App\Console\Cron\Weekly;
|
2019-10-30 21:55:32 +08:00
|
|
|
use App\Services\CronService;
|
2017-06-09 02:28:26 +08:00
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
|
|
|
|
class Kernel extends ConsoleKernel
|
|
|
|
{
|
|
|
|
/**
|
2021-03-03 04:43:34 +08:00
|
|
|
* Define the application's command schedule. How this works... according to the command
|
|
|
|
* time, an event gets send out with the appropriate time (e.g, hourly sends an hourly event)
|
|
|
|
*
|
|
|
|
* Then the CronServiceProvider has the list of cronjobs which then run according to the events
|
|
|
|
* and then calls those at the proper times.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
|
|
*
|
2017-06-09 02:28:26 +08:00
|
|
|
* @return void
|
|
|
|
*/
|
2018-03-17 09:12:56 +08:00
|
|
|
protected function schedule(Schedule $schedule): void
|
2017-06-09 02:28:26 +08:00
|
|
|
{
|
2021-05-22 00:31:32 +08:00
|
|
|
// If not using the queue worker then run those via cron
|
|
|
|
if (!config('queue.worker', false)) {
|
|
|
|
$schedule->command(JobQueue::class)
|
|
|
|
->everyMinute()
|
|
|
|
->withoutOverlapping();
|
|
|
|
}
|
2021-05-20 23:54:07 +08:00
|
|
|
|
2022-02-12 05:24:06 +08:00
|
|
|
/*
|
|
|
|
* NOTE: IF MORE TASKS ARE ADDED, THEY ALSO MUST BE ADDED TO THE CRON.PHP
|
|
|
|
*/
|
|
|
|
$schedule->command(FiveMinute::class)->everyFiveMinutes();
|
|
|
|
$schedule->command(FifteenMinute::class)->everyFifteenMinutes();
|
|
|
|
$schedule->command(ThirtyMinute::class)->everyThirtyMinutes();
|
2018-03-17 09:12:56 +08:00
|
|
|
$schedule->command(Nightly::class)->dailyAt('01:00');
|
2022-02-12 05:24:06 +08:00
|
|
|
$schedule->command(Hourly::class)->hourly();
|
2018-03-17 09:12:56 +08:00
|
|
|
$schedule->command(Weekly::class)->weeklyOn(0);
|
|
|
|
$schedule->command(Monthly::class)->monthlyOn(1);
|
2019-08-31 03:59:17 +08:00
|
|
|
|
|
|
|
// When spatie-backups runs
|
2021-03-05 20:33:42 +08:00
|
|
|
/*if (config('backup.backup.enabled', false) === true) {
|
2021-03-05 19:00:36 +08:00
|
|
|
$schedule->command('backup:clean')->daily()->at('01:00');
|
|
|
|
$schedule->command('backup:run')->daily()->at('02:00');
|
2021-03-05 20:33:42 +08:00
|
|
|
}*/
|
2019-10-30 21:55:32 +08:00
|
|
|
|
|
|
|
// Update the last time the cron was run
|
2021-03-03 04:43:34 +08:00
|
|
|
/** @var CronService $cronSvc */
|
2019-10-30 22:23:31 +08:00
|
|
|
$cronSvc = app(CronService::class);
|
|
|
|
$cronSvc->updateLastRunTime();
|
2017-06-09 02:28:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the Closure based commands for the application.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2017-06-09 02:28:26 +08:00
|
|
|
* @return void
|
|
|
|
*/
|
2018-03-17 09:12:56 +08:00
|
|
|
protected function commands(): void
|
2017-06-09 02:28:26 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
$this->load(__DIR__.'/Cron');
|
2017-06-09 02:28:26 +08:00
|
|
|
}
|
|
|
|
}
|