【问题标题】:Laravel queue stalls when used with sentry与哨兵一起使用时 Laravel 队列停止
【发布时间】:2019-09-09 18:10:22
【问题描述】:

我有一个用 laravel 编写的工作项目,我已经集成了 Sentry 来监控错误,我按照他们网站上的说明进行操作,基本上只是

composer 需要 sentry/sentry-laravel

在我的 App/Exceptions/Handler.php 中

if (app()->bound('sentry') && $this->shouldReport($exception)) {
    app('sentry')->captureException($exception);
}

现在这工作正常,我在哨兵中看到错误。 但是在我使用队列的应用程序的另一端,例如我有“忘记密码”通知,它实际上实现了 ShouldQueue 类:

<?php

namespace App\Notifications\Auth;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class PasswordResetRequest extends Notification implements ShouldQueue
{
    use Queueable;

    protected $token;

    public function __construct($token)
    {
        $this->token = $token;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $url = url('/password/find/'.$this->token);
        return (new MailMessage)
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url($url))
            ->line('If you did not request a password reset, no further action is required.');
    }
}

当触发按预期工作时,我在作业表中有一条新记录(我有数据库作为队列驱动程序)

现在当我开始工作时

php 工匠队列:工作

它会一遍又一遍地停止上次工作的工作

没有邮件发送或接收...

顺便说一句,这只是当我在哨兵中报告时,如果我在 report() 方法中删除 App/Exceptions/Handler.php 中的那些行,这一切都很好,如果我从通知中删除队列它也有效,只有哨兵错误报告和通知队列的组合让我成为一个大问题。

【问题讨论】:

    标签: php laravel sentry


    【解决方案1】:

    不幸的是,Sentry-laravel 不适用于队列。

    请在他们的 GitHub 存储库上查看此问题以获取有关它的更多信息:

    https://github.com/getsentry/sentry-laravel/issues/18

    他们正在尝试解决另一个问题(未解决):

    https://github.com/getsentry/sentry-laravel/pull/228

    如果您现在确实需要将这些日志放入队列中,您应该使用https://github.com/twineis/raven-php。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-04
      • 2013-01-15
      • 1970-01-01
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 2014-01-21
      • 1970-01-01
      相关资源
      最近更新 更多