From 1703166f8fceea1a40ace1f7c4c444dbfffbf7a6 Mon Sep 17 00:00:00 2001 From: GallopYD <18859669020@163.com> Date: Wed, 8 Mar 2023 15:49:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=98=9F=E5=88=97?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/JobRunCommand.php | 30 +++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/JobRunCommand.php b/app/Console/Commands/JobRunCommand.php index 8b19644..a5997ea 100644 --- a/app/Console/Commands/JobRunCommand.php +++ b/app/Console/Commands/JobRunCommand.php @@ -85,19 +85,23 @@ public function handle() $this->log->info('Get whitelist success'); while ($job = $this->takeJob()) { - $keyword = $job->keyword; - $this->log->info('Get a job from the queue', ['keyword' => $keyword]); - $configJob = ConfigJob::where('keyword', $keyword)->first(); - $configJob->last_scan_at = date('Y-m-d H:i:s'); - $page = 1; - do { - $client = $this->service->getClient(); - $data = $this->searchCode($client, $keyword, $page); - $count = $this->store($data, $configJob); - $this->log->info('Store record', ['count' => $count]); - $lastResponse = ResponseMediator::getPagination($client->getLastResponse()); - } while ($lastResponse['next'] && (++$page <= $configJob->scan_page)); - $configJob->save(); + try { + $keyword = $job->keyword; + $this->log->info('Get a job from the queue', ['keyword' => $keyword]); + $configJob = ConfigJob::where('keyword', $keyword)->first(); + $configJob->last_scan_at = date('Y-m-d H:i:s'); + $page = 1; + do { + $client = $this->service->getClient(); + $data = $this->searchCode($client, $keyword, $page); + $count = $this->store($data, $configJob); + $this->log->info('Store record', ['count' => $count]); + $lastResponse = ResponseMediator::getPagination($client->getLastResponse()); + } while ($lastResponse['next'] && (++$page <= $configJob->scan_page)); + $configJob->save(); + } catch (Exception $exception) { + $this->log->error($exception->getMessage()); + } $job->delete(); }