Update
This commit is contained in:
@@ -16,6 +16,8 @@ class ProcessCrawlShotJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $timeout = 120;
|
||||||
|
|
||||||
protected string $jobUuid;
|
protected string $jobUuid;
|
||||||
|
|
||||||
public function __construct(string $jobUuid)
|
public function __construct(string $jobUuid)
|
||||||
@@ -26,7 +28,7 @@ public function __construct(string $jobUuid)
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$job = CrawlShotJob::where('uuid', $this->jobUuid)->first();
|
$job = CrawlShotJob::where('uuid', $this->jobUuid)->first();
|
||||||
|
|
||||||
if (!$job) {
|
if (!$job) {
|
||||||
Log::error("CrawlShotJob not found: {$this->jobUuid}");
|
Log::error("CrawlShotJob not found: {$this->jobUuid}");
|
||||||
return;
|
return;
|
||||||
@@ -52,10 +54,9 @@ public function handle(): void
|
|||||||
'status' => 'completed',
|
'status' => 'completed',
|
||||||
'completed_at' => now()
|
'completed_at' => now()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error("Job {$this->jobUuid} failed: " . $e->getMessage());
|
Log::error("Job {$this->jobUuid} failed: " . $e->getMessage());
|
||||||
|
|
||||||
$job->update([
|
$job->update([
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'error_message' => $e->getMessage(),
|
'error_message' => $e->getMessage(),
|
||||||
@@ -68,9 +69,9 @@ private function saveCrawlResult(CrawlShotJob $job, string $html): void
|
|||||||
{
|
{
|
||||||
$filename = "{$job->uuid}.html";
|
$filename = "{$job->uuid}.html";
|
||||||
$path = "crawlshot/html/{$filename}";
|
$path = "crawlshot/html/{$filename}";
|
||||||
|
|
||||||
Storage::put($path, $html);
|
Storage::put($path, $html);
|
||||||
|
|
||||||
$job->update(['file_path' => $path]);
|
$job->update(['file_path' => $path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,9 +81,9 @@ private function saveScreenshotResult(CrawlShotJob $job, array $result): void
|
|||||||
$format = $parameters['format'] ?? 'jpg';
|
$format = $parameters['format'] ?? 'jpg';
|
||||||
$filename = "{$job->uuid}.{$format}";
|
$filename = "{$job->uuid}.{$format}";
|
||||||
$path = "crawlshot/images/{$filename}";
|
$path = "crawlshot/images/{$filename}";
|
||||||
|
|
||||||
Storage::put($path, $result['data']);
|
Storage::put($path, $result['data']);
|
||||||
|
|
||||||
$job->update(['file_path' => $path]);
|
$job->update(['file_path' => $path]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'waits' => [
|
'waits' => [
|
||||||
'redis:default' => 60,
|
'redis:default' => 120,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -189,9 +189,9 @@
|
|||||||
'maxProcesses' => 1,
|
'maxProcesses' => 1,
|
||||||
'maxTime' => 0,
|
'maxTime' => 0,
|
||||||
'maxJobs' => 0,
|
'maxJobs' => 0,
|
||||||
'memory' => 128,
|
'memory' => 4096,
|
||||||
'tries' => 1,
|
'tries' => 1,
|
||||||
'timeout' => 60,
|
'timeout' => 120,
|
||||||
'nice' => 0,
|
'nice' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user