Files
boursecu_server/app/Console/Commands/PriceTickLoopCommand.php
T

33 lines
861 B
PHP
Raw Normal View History

2026-06-14 12:33:29 +03:30
<?php
namespace App\Console\Commands;
use App\Services\LivePriceTickService;
use Illuminate\Console\Command;
/**
* هر دقیقه ۶ بار prices:tick — برای schedule:run (فاصله ۱۰ ثانیه).
*/
class PriceTickLoopCommand extends Command
{
protected $signature = 'prices:tick-loop {--iterations=6} {--interval=10}';
protected $description = 'Run prices:tick several times per minute (default: 6× every 10s)';
public function handle(LivePriceTickService $tickService): int
{
$iterations = max(1, (int) $this->option('iterations'));
$interval = max(1, (int) $this->option('interval'));
for ($i = 0; $i < $iterations; $i++) {
$tickService->tick();
if ($i < $iterations - 1) {
sleep($interval);
}
}
return self::SUCCESS;
}
}