以下方法来自地平线存储库
/**
* Handle the event.
*
* @param \Laravel\Horizon\Events\SupervisorLooped $event
* @return void
*/
public function handle(SupervisorLooped $event)
{
if (! $this->dueToMonitor()) {
return;
}
// Here we will calculate the wait time in seconds for each of the queues that
// the application is working. Then, we will filter the results to find the
// queues with the longest wait times and raise events for each of these.
$results = app(WaitTimeCalculator::class)->calculate();
$long = collect($results)->filter(function ($wait, $queue) {
return $wait > (config("horizon.waits.{$queue}") ?? 60);
});
// Once we have determined which queues have long wait times we will raise the
// events for each of the queues. We'll need to separate the connection and
// queue names into their own strings before we will fire off the events.
$long->each(function ($wait, $queue) {
[$connection, $queue] = explode(':', $queue, 2);
event(new LongWaitDetected($connection, $queue, $wait));
});
}
LongWaitDetected
事件触发电子邮件。“31941 秒”是您webcam
队列的等待时间。每当supervisor
开始循环时,它就会触发MonitorWaitTimes
并且上面的代码有效。
如果您不想收到这封电子邮件,请将您的队列名称添加到waits
阵列中的地平线配置中,并带有大量数字。
'waits' => [
'redis:default' => 60,
'redis:webcam' => 1514124141
],
但请记住;这可能表明某些流程/作业无法正常工作。30K 秒可能是一个指示。