2026-01-24 14:03:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console;
|
|
|
|
|
|
|
|
|
|
use App\Console\Commands\Price;
|
|
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
|
|
|
|
|
|
class Kernel extends ConsoleKernel
|
|
|
|
|
{
|
|
|
|
|
protected $commands = [
|
|
|
|
|
Price::class,
|
|
|
|
|
];
|
|
|
|
|
/**
|
|
|
|
|
* Define the application's command schedule.
|
|
|
|
|
*
|
|
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function schedule(Schedule $schedule)
|
|
|
|
|
{
|
|
|
|
|
// $schedule->command('inspire')->hourly();
|
2026-02-16 09:29:37 +00:00
|
|
|
$schedule->call(function () {
|
|
|
|
|
// حلقه برای اجرای 6 بار در یک دقیقه (هر 10 ثانیه)
|
|
|
|
|
for ($i = 0; $i < 6; $i++) {
|
|
|
|
|
// \Illuminate\Support\Facades\Log::info("Update process ran at: " . now());
|
|
|
|
|
|
|
|
|
|
// فراخوانی کامند ما
|
|
|
|
|
\Illuminate\Support\Facades\Artisan::call('product:update-status');
|
|
|
|
|
|
|
|
|
|
// 10 ثانیه صبر کن (به جز دور آخر که نیاز نیست اسکریپت باز بماند)
|
|
|
|
|
if ($i < 5) {
|
|
|
|
|
sleep(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})->everyMinute()->name('update_products_every_20s')->withoutOverlapping();
|
2026-01-24 14:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register the commands for the application.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function commands()
|
|
|
|
|
{
|
|
|
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
|
|
|
|
|
|
require base_path('routes/console.php');
|
|
|
|
|
}
|
|
|
|
|
}
|