/** * {@inheritdoc } */ protected function transformListToTableBody($list) { $result = []; foreach ($list as $queue) { $result[$queue] = [$queue, Job::where('queue', '=', $queue)->count()]; } return $result; }
/** * Walk thru all jobs and queues to make sure they are working, including firing a testjob at them * * @return boolean */ private function checkQueues() { $jobLimit = new Carbon('1 hour ago'); $hangs = []; foreach (config('queue.queues') as $queue) { /* * Fire an test jobs into the abuseio queue selected. * Handling of the result is done at the QueueTest->failed() method */ $this->dispatch(new QueueTest($queue)); /* * Check all created jobs not to be older then 1 hour */ $jobs = Job::where('queue', '=', $queue)->get(); foreach ($jobs as $job) { $created = $job->created_at; if ($jobLimit->gt($created)) { $hangs[] = $job; } } } /* * Send alarm on hanging jobs */ if (count($hangs) != 0) { AlertAdmin::send("Alert: There are " . count($hangs) . " jobs that are stuck:" . PHP_EOL . PHP_EOL . implode(PHP_EOL, $hangs)); } /* * Check for any kind of failed jobs, if any found start alarm bells */ $failed = $this->laravel['queue.failer']->all(); if (count($failed) != 0) { AlertAdmin::send("Alert: There are " . count($failed) . " jobs that have failed:" . PHP_EOL . PHP_EOL . implode(PHP_EOL, $failed)); } if (count($failed) != 0 || count($hangs) != 0) { return false; } return true; }
/** * {@inheritdoc } */ protected function findWithCondition($filter) { return Job::where('queue', '=', "{$this->argument('name')}")->get(); }
/** * @param $filter * * @return mixed */ protected function findWithCondition($filter) { return Job::where('queue', 'like', "%{$filter}%")->get(); }
/** * Walk thru all jobs and queues to make sure they are working, including firing a testjob at them. * * @return bool */ private function checkQueues() { Log::info(get_class($this) . ': Housekeeper is starting queue checks'); $jobLimit = new Carbon('1 hour ago'); $hangs = []; foreach (config('queue.queues') as $queue) { /* * Fire an test jobs into the abuseio queue selected. * Handling of the result is done at the QueueTest->failed() method */ $this->dispatch(new QueueTest($queue)); /* * Check all created jobs not to be older then 1 hour */ $jobs = Job::where('queue', '=', $queue)->get(); foreach ($jobs as $job) { $created = $job->created_at; if ($jobLimit->gt($created)) { $hangs[] = $job; } } } /* * Send alarm on hanging jobs */ $hangCount = count($hangs); if ($hangCount != 0) { Log::warning(get_class($this) . ": Housekeeper detected {$hangCount} jobs that are stuck in one or more queues!"); if (config('main.housekeeping.enable_queue_problem_alerts')) { AlertAdmin::send("Alert: There are {$hangCount} jobs that are stuck:" . PHP_EOL . PHP_EOL . implode(PHP_EOL, $hangs)); } } /* * Check for any kind of failed jobs, if any found start alarm bells */ $failed = $this->laravel['queue.failer']->all(); $failedCount = count($failed); if ($failedCount != 0) { // Reset object to string for reporting foreach ($failed as $key => $job) { $failed[$key] = implode(' ', get_object_vars($job)); } Log::warning(get_class($this) . ": Housekeeper detected failed {$failedCount} jobs which need to be handled!"); if (config('main.housekeeping.enable_queue_problem_alerts')) { AlertAdmin::send("Alert: There are {$failedCount} jobs that have failed:" . PHP_EOL . PHP_EOL . implode(PHP_EOL, $failed)); } } if ($hangCount != 0 || $failedCount != 0) { return false; } return true; }