以下方法来自horizon repository
/**
* 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 并且上面的代码有效。
如果您不想收到此电子邮件,请将您的队列名称添加到您的 Horizon 配置中的 waits 数组中,并带有一个大数字。
'waits' => [
'redis:default' => 60,
'redis:webcam' => 1514124141
],
但请记住;这可能表明某些流程/作业无法正常工作。 30K 秒可能是一个指标。