dt = new Carbon(); } /** * Execute the console command. * * @return int */ public function handle() { $url = 'https://kelvinkamara.com'; while(true) { /** * We can also dispatch jobs in parallel (See https://laravel.com/docs/9.x/queues#chains-within-batches) */ $code = $this->call('browser:scrape', ['url' => $url,]); if (2 === $code) { $seconds = 2 * 60; Log::info('Sleeping for '.$seconds.' seconds'); ++$this->retries; if ($this->maxRetries <= $this->retries) { $this->handleMaxRetryLimitReached($url); break; } sleep($seconds); } else { $this->retries = 0; } } return 0; } protected function handleMaxRetryLimitReached(string $url) { $msg = 'Hit max retries of '.$this->maxRetries.' for '.$url; Log::alert($msg); // (new Error([ 'error' => $msg, ]))->save(); } }