From 21f4df11f8f04d4e5f52060e3a5785b35e1f252f Mon Sep 17 00:00:00 2001 From: ct Date: Tue, 12 Aug 2025 04:32:37 +0800 Subject: [PATCH] Update --- app/Jobs/ProcessCrawlShotJob.php | 17 +++++++++-------- config/horizon.php | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/Jobs/ProcessCrawlShotJob.php b/app/Jobs/ProcessCrawlShotJob.php index e14d348..ca9df30 100644 --- a/app/Jobs/ProcessCrawlShotJob.php +++ b/app/Jobs/ProcessCrawlShotJob.php @@ -16,6 +16,8 @@ class ProcessCrawlShotJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + public $timeout = 120; + protected string $jobUuid; public function __construct(string $jobUuid) @@ -26,7 +28,7 @@ public function __construct(string $jobUuid) public function handle(): void { $job = CrawlShotJob::where('uuid', $this->jobUuid)->first(); - + if (!$job) { Log::error("CrawlShotJob not found: {$this->jobUuid}"); return; @@ -52,10 +54,9 @@ public function handle(): void 'status' => 'completed', 'completed_at' => now() ]); - } catch (\Exception $e) { Log::error("Job {$this->jobUuid} failed: " . $e->getMessage()); - + $job->update([ 'status' => 'failed', 'error_message' => $e->getMessage(), @@ -68,9 +69,9 @@ private function saveCrawlResult(CrawlShotJob $job, string $html): void { $filename = "{$job->uuid}.html"; $path = "crawlshot/html/{$filename}"; - + Storage::put($path, $html); - + $job->update(['file_path' => $path]); } @@ -80,9 +81,9 @@ private function saveScreenshotResult(CrawlShotJob $job, array $result): void $format = $parameters['format'] ?? 'jpg'; $filename = "{$job->uuid}.{$format}"; $path = "crawlshot/images/{$filename}"; - + Storage::put($path, $result['data']); - + $job->update(['file_path' => $path]); } -} \ No newline at end of file +} diff --git a/config/horizon.php b/config/horizon.php index facdb30..2f24fc6 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -85,7 +85,7 @@ */ 'waits' => [ - 'redis:default' => 60, + 'redis:default' => 120, ], /* @@ -189,9 +189,9 @@ 'maxProcesses' => 1, 'maxTime' => 0, 'maxJobs' => 0, - 'memory' => 128, + 'memory' => 4096, 'tries' => 1, - 'timeout' => 60, + 'timeout' => 120, 'nice' => 0, ], ],