Files
boursecu_server/app/Console/Commands/PriceTickLoopCommand.php
T
2026-06-14 12:33:29 +03:30

33 lines
861 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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;
}
}