我如何才能详细了解我的 Laravel 排队作业失败的原因?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34485265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:54:28  来源:igfitidea点击:

How can I learn more about why my Laravel Queued Job failed?

phplaravelqueue

提问by slifty

The Situation

情况

I'm using Laravel Queues to process large numbers of media files, an individual job is expected to take minutes (lets just say up to an hour).

我正在使用 Laravel 队列处理大量媒体文件,预计单个作业需要几分钟(可以说最多一个小时)。

I am using Supervisor to run my queue, and I am running 20 processes at a time. My supervisor config file looks like this:

我正在使用 Supervisor 来运行我的队列,并且我一次运行 20 个进程。我的主管配置文件如下所示:

[program:duplitron-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/duplitron/artisan queue:listen database --timeout=0 --memory=500 --tries=1
autostart=true
autorestart=true
user=duplitron
numprocs=20
redirect_stderr=true
stdout_logfile=/var/www/duplitron/storage/logs/duplitron-worker.log

In my duplitron-worker.logI noticed Failed: Illuminate\Queue\CallQueuedHandler@calloccurs occasionally and I would like to better understand what exactly is failing. Nothing appears in my laravel.log file (which is where exceptions would normally appear).

在我duplitron-worker.log我注意到Failed: Illuminate\Queue\CallQueuedHandler@call偶尔会发生,我想更好地了解究竟是什么失败。我的 laravel.log 文件中没有任何内容(通常会出现异常的地方)。

The Question

问题

Is there a handy way for me to learn more about what is causing my job to fail?

是否有一种方便的方法可以让我更多地了解导致我的工作失败的原因?

回答by Stan Smulders

In the newer Laravel versions there's an exceptioncolumn in the failed_jobstable that has all the info you need. Thanks cdarken and Toskan for pointing this out!

在较新的 Laravel 版本exception中,failed_jobs表格中有一列包含您需要的所有信息。感谢 cdarken 和 Toskan 指出这一点!

==== OLD METHOD BELOW

==== 下面的旧方法

Here's what I always do, but first - make sure you have a failed-jobs table! It's well documented, look it up :)

这是我经常做的,但首先 - 确保你有一个失败的工作表!它有据可查,查一下:)

  1. Run the php artisan queue:failedcommand to list all the failed jobs, and pick the one you're after. Write the ID down.

  2. Then, make sure to stop your queue with supervisorctl stop all duplitron-worker:

  3. Lastly, make sure your .env setting for APP_DEBUG= true.

  4. Then run php artisan queue:retry {step_job_1_id}

  5. Now manually runphp artisan queue:listen --timeout=XXX

  1. 运行该php artisan queue:failed命令以列出所有失败的作业,然后选择您想要的作业。写下身。

  2. 然后,确保停止您的队列 supervisorctl stop all duplitron-worker:

  3. 最后,确保您的 .env 设置为APP_DEBUG= true。

  4. 然后运行 php artisan queue:retry {step_job_1_id}

  5. 现在手动运行php artisan queue:listen --timeout=XXX

If the error is structural (and most are), you should get the failure with debug stack in your log file.

如果错误是结构性的(并且大多数是),您应该在日志文件中通过调试堆栈获得失败。

Good luck with debugging :-)

祝调试顺利:-)

回答by Toskan

as @cdarken pointed out, the exception can be found in your database table failed_jobscolumn name exception. Thanks @cdarken I wish his answer would be an answer and not a comment.

正如@cdarken 所指出的,异常可以在您的数据库表failed_jobs列名中找到exception。谢谢@cdarken 我希望他的回答是一个答案而不是一个评论。

回答by ibrahim.suez

Worked for me, in vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php Just remove "use Illuminate\Queue\SerializesModels;" Line 6 & modify Line 11 to "use Queueable;"

对我来说有效,在 vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php 中删除“use Illuminate\Queue\SerializesModels;” 第 6 行 & 将第 11 行修改为“使用 Queueable”;