<?php
namespace App\Providers;
use App\Console\Commands\SendEmailsCommand;
use App\Jobs\Heartbeat;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Stringable;
class ScheduleProvider extends ServiceProvider
{
/**
* Bootstrap services.
*/
public function boot(): void
{
Schedule::exec('php artisan queue:work --queue=default,emails --max-time=60 --memory=128')
->cron('* * * * *');
//->timezone('America/New_York')
//->runInBackground();
//->onOneServer();
Schedule::call(function () {
Log::info("Schedule cron 5 min");
})->cron('*/5 * * * *');
Schedule::call(function () {
Log::info("Schedule cron 5 sec");
DB::table('recent_users')->delete();
})->everyFiveSeconds();
Schedule::job(new Heartbeat, 'heartbeats', 'sqs')->everyTenMinutes();
Schedule::command(SendEmailsCommand::class, ['Alexia', '--force'])->daily();
//->evenInMaintenanceMode();
//->runInBackground();
Schedule::command('report:generate')
->daily()
->sendOutputTo($filePath)
->emailOutputTo('[email protected]')
->emailOutputOnFailure('[email protected]')
->onSuccess(function (Stringable $output) {
// The task succeeded...
})
->onFailure(function (Stringable $output) {
// The task failed...
})
->after(function () {
// The task has executed...
})
->thenPing($url);
}
}