37 lines
996 B
PHP
37 lines
996 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\LivePriceTickService;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* حلقه بینهایت — برای supervisor: php artisan prices:tick-daemon
|
|
*/
|
|
class PriceTickDaemonCommand extends Command
|
|
{
|
|
protected $signature = 'prices:tick-daemon {--interval=10}';
|
|
|
|
protected $description = 'Continuously refresh montzar/zaarbox/products every N seconds (supervisor)';
|
|
|
|
public function handle(LivePriceTickService $tickService): int
|
|
{
|
|
$interval = max(1, (int) $this->option('interval'));
|
|
|
|
$this->info("Price tick daemon started (every {$interval}s). Ctrl+C to stop.");
|
|
|
|
while (true) {
|
|
try {
|
|
$tickService->tick();
|
|
} catch (\Throwable $e) {
|
|
Log::error('prices:tick-daemon failed', [
|
|
'message' => $e->getMessage(),
|
|
]);
|
|
}
|
|
|
|
sleep($interval);
|
|
}
|
|
}
|
|
}
|