fix price force refresh 2
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user