Laravel 与哨兵一起使用时队列停止
Laravel queue stalls when used with sentry
我有一个用 laravel 编写的工作项目,我集成了 Sentry 来监控错误,我按照他们网站上的说明进行操作,基本上只是
composer require sentry/sentry-laravel
在我的 App/Exceptions/Handler.php
if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}
现在这工作正常,我看到哨兵中的错误。
但是在应用程序的另一端,无论我在哪里使用队列,例如我有 "forgot password" 通知并且它实现了 ShouldQueue class,实际上:
<?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.');
}
}
当触发按预期工作时,我在作业中有一个新记录table(我有数据库作为队列驱动程序)
现在当我开始我的工人时
php artisan queue:work
它停止了它一遍又一遍地工作上一个作业
没有邮件发送或接收...
顺便说一句,这只是当我在哨兵中报告时,如果我在 App/Exceptions/Handler.php 中删除那些行在 report() 方法中一切都很好,如果我从中删除队列通知它有效,只有哨兵错误报告和通知队列的组合让我成为一个大问题。
不幸的是,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。
我有一个用 laravel 编写的工作项目,我集成了 Sentry 来监控错误,我按照他们网站上的说明进行操作,基本上只是
composer require sentry/sentry-laravel
在我的 App/Exceptions/Handler.php
if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}
现在这工作正常,我看到哨兵中的错误。 但是在应用程序的另一端,无论我在哪里使用队列,例如我有 "forgot password" 通知并且它实现了 ShouldQueue class,实际上:
<?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.');
}
}
当触发按预期工作时,我在作业中有一个新记录table(我有数据库作为队列驱动程序)
现在当我开始我的工人时
php artisan queue:work
它停止了它一遍又一遍地工作上一个作业
没有邮件发送或接收...
顺便说一句,这只是当我在哨兵中报告时,如果我在 App/Exceptions/Handler.php 中删除那些行在 report() 方法中一切都很好,如果我从中删除队列通知它有效,只有哨兵错误报告和通知队列的组合让我成为一个大问题。
不幸的是,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。