phpvms/app/Console/Kernel.php

56 lines
1.7 KiB
PHP
Raw Normal View History

2017-06-09 02:28:26 +08:00
<?php
namespace App\Console;
2018-08-25 01:07:14 +08:00
use App\Console\Cron\Hourly;
use App\Console\Cron\Monthly;
use App\Console\Cron\Nightly;
use App\Console\Cron\Weekly;
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
{
/**
* 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
*/
protected function schedule(Schedule $schedule): void
2017-06-09 02:28:26 +08:00
{
$schedule->command(Nightly::class)->dailyAt('01:00');
$schedule->command(Weekly::class)->weeklyOn(0);
$schedule->command(Monthly::class)->monthlyOn(1);
2018-08-25 01:07:14 +08:00
$schedule->command(Hourly::class)->hourly();
// When spatie-backups runs
2021-03-05 19:00:36 +08:00
if (config('backup.backup.enabled', false) === true) {
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
}
// Update the last time the cron was run
/** @var CronService $cronSvc */
$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
*/
protected function commands(): void
2017-06-09 02:28:26 +08:00
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__.'/Cron');
2017-06-09 02:28:26 +08:00
}
}